Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

android - Cordova / Ionic build error (sometimes): don't have required environment

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
thissenDropboxMobileProjectshelloplatformsandro
idcordovauild.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
thissenDropboxMobilePro
jectshelloplatformsandroidcordovauild.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Copy and paste this to your environment variable path:

%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...