I have just started dabbling in Cordova / Ionic to make Android / iOS apps with HTML5 / js, and so far I have gotten sample / tutorial apps to work sometimes, but not every time.
I am working on Windows and am trying to build my projects for Android for now.
After a couple tries, I am no longer able to build my apps, even completely "blank" template apps that I did not change at all. I tried creating apps via Cordova
cordova create hello com.example.hello HelloWorld
cd hello
cordova build android
or Ionic
ionic start test sidemenu
cd start
ionic build android
In both cases I get the same error:
Running command: C:\Users\nthissen\Dropbox\Mobile\Projects\hello\platforms\andro
id\cordova\build.bat
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
ERROR building one of the platforms: Error: C:\Users\nthissen\Dropbox\Mobile\Pro
jects\hello\platforms\android\cordova\build.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Yes, I do have the Android SDK and everything installed. The strange thing is: when I restart my computer and try it immediately, it works without problems and I'm even able to emulate / run the app. After a couple more tries, edits to the source code, etc (I am not quite sure what's causing it), it stops working and I cannot even build a newly created project anymore.
What's going on? Why does it work right after a reboot, but stops working for seemingly random reason?
Build web assets and prepare your app for any platform targets ionic build will perform an Ionic build, which compiles web assets and prepares them for deployment. For Ionic/Cordova apps, the CLI will run cordova prepare, which copies the built web assets into the Cordova platforms that you’ve installed.
Use Cordova to build for Android and iOS platform targets. Like running cordova build directly, ionic cordova build also builds web assets from ionic build and provides friendly checks for Android and iOS platforms. To pass additional options to the Cordova CLI, use the -- separator after the Ionic CLI arguments.
To pass additional options to the Cordova CLI, use the -- separator after the Ionic CLI arguments. The Cordova CLI requires a separator for platform-specific arguments for Android builds, so an additional separator is required for the Ionic CLI, but it is not required for iOS builds.
The Cordova CLI requires a separator for platform-specific arguments for Android builds, so an additional separator is required for the Ionic CLI, but it is not required for iOS builds. See the example commands for usage with separators. To avoid using flags, consider using --buildConfig with a build.json file.
Copy and paste this to your environment variable path:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
Then open Android Studio or Eclipse and make a rebuild to some project into the environment and try to build your Cordova project. Hope it will help. That solved the problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With