ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

bug: Command failed with exit code 2 You may not have the required environment or OS to build this project

Open adamdbradley opened this issue 11 years ago • 87 comments

From @shivanshuit914 on March 3, 2015 19:15

Type: bug

Platform: desktop browser

> ionic build ios

ERROR building one of the platforms: Error: /Applications/MAMP/htdocs/myApp/platforms/ios/cordova/build: Command failed with exit code 2 You may not have the required environment or OS to build this project Error: /Applications/MAMP/htdocs/myApp/platforms/ios/cordova/build: Command failed with exit code 2 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5)

OS Mac Maverich, have followed this tutorial http://ionicframework.com/docs/guide/installation.html

Copied from original issue: driftyco/ionic#3225

adamdbradley avatar Mar 04 '15 17:03 adamdbradley

hi @wtfiwtz,

I've already try your suggestion to follow the step of installation android sdk from the link. But the result is still the same. And I think the problem is on my mac os x version. Right now i'm using mac os x lion (10.7.5) and when i browse the android sdk page, its say that minimum requirement for the latest android sdk is mac os x 10.8.5 which is moutain lion.

Maybe you have another solution for this matter?

thanks.

h4rliano avatar Sep 28 '15 15:09 h4rliano

@h4rliano, sorry I mixed up Ionic and Facebook react-native in my previous post (now deleted) as I've built some quick'n'dirty apps in both of these technologies recently.

Can you run the aapt tool manually? What is your $PATH set to?

Maybe it is possible to run the Gradle task separately using the Gradle CLI, to see if that succeeds.

wtfiwtz avatar Sep 29 '15 03:09 wtfiwtz

hi @wtfiwtz,

this is the result after I run aapt command: Arnos-MacBook-6:~ Arno$ aapt It appears you do not have 'build-tools-23.0.0' installed. Use the 'android' tool to install them: android update sdk --no-ui --filter 'build-tools-23.0.0'

it said that I ave not installed build tools 23.0.0, but if I check from android sdk manager the build tools already installed for 23.0.1. Here is the screenshot

screen shot 2015-09-29 at 10 53 55 am

and this is my $PATH information: export ANDROID_HOME=/usr/local/opt/android-sdk export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

Is there something that i missed?

h4rliano avatar Sep 29 '15 04:09 h4rliano

Maybe try this:

http://stackoverflow.com/questions/30859449/clean-blank-android-app-fails-to-build-failed-to-find-build-tools-revision-23

It seems to be looking for version 23.0.0 instead of 23.0.1... also you might need to change the paths to point to the correct place (/Users/Arno/android-sdk-macosx/build-tools/23.0.0/aapt, vs. /usr/local/opt/android-sdk/platform-tools). Looks to be all jumbled up to me.

wtfiwtz avatar Sep 29 '15 04:09 wtfiwtz

i find out this is because of user rights permissions and Java version problem.

following things i done to resolved this issue :

  1. create user account in windows are mac or linux

2 . completely remove the Java and Android SDK

clear your temp and system cache files using ccleaner

  1. install node

4.install java 5. install Android SDK

now try it will work........:)

isathish avatar Sep 29 '15 09:09 isathish

hi i've the same problems when building.

BSPharaon avatar Oct 06 '15 22:10 BSPharaon

In case it helps anyone (ios build); I had to remove the ios platform AND remove and re-add all plugins, then add the ios platform back.

cnd5041 avatar Oct 31 '15 17:10 cnd5041

Just had this problem on ElCapitan building iOs and removing then adding ios-deploy and ios-sim did the trick in case this can help someone.

npm install -g ios-sim npm install -g ios-deploy

apavillet avatar Nov 03 '15 22:11 apavillet

@ijames 'ionic reset state' solved this issue for multiple developers hitting the same build environment. Sounds like downgrading etc would reset states as well so ljames might be on to something more high level. Great job man!

druearmstrong avatar Nov 09 '15 21:11 druearmstrong

Me this error happened when I downloaded the source from another machine. The problem was the plugins that were installed on the other machine did not exist and where I downloaded. I had to reinstall all plug

pablolopesk8 avatar Nov 11 '15 19:11 pablolopesk8

I had the same issue, the only thing that worked was @pablolopesk8 answer, after 2.5 hours of struggle. Thanks man! (The problem occurred in our case after using ionic add plugin instead of cordova add plugin for some plugin I can't remember, I think it was keyboard, it might have been two versions simultaneously added)

thtro avatar Nov 12 '15 13:11 thtro

Can any body guide me,i am new to ionic developement i am facing problem during platform add android. Error:Running command: cmd "/s /c "C:\Users\PC2.cordova\lib\npm_cache\cordova-android\4.1.1\package\bin\create.bat D:\IONIC\Demo\platforms\android com.ionicframework.demo937629 Dem o --cli"" Error: cmd: Command failed with exit code ENOENT

errr

maheshts avatar Nov 17 '15 06:11 maheshts

@maheshts I'm not usually a Windows user now but ENOENT means the file doesn't exist... check to see what files are missing - e.g. C:\Users\PC2.cordova\lib\npm_cache\cordova-android\4.1.1\package\bin\create.bat, or D:\IONIC\Demo\platforms\android com.ionicframework.demo937629

wtfiwtz avatar Nov 17 '15 23:11 wtfiwtz

Sou I got this after I install wikitude plugin, without it all work fine. I am building for ios and this is my ionic info result.

Cordova CLI: 5.0.0 Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.0 Ionic CLI Version: 1.7.7 Ionic App Lib Version: 0.6.3 ios-deploy version: 1.8.3 ios-sim version: 5.0.4 OS: Mac OS X El Capitan Node Version: v0.12.7 Xcode version: Xcode 7.1.1 Build version 7B1005

HELP :D

vjekofalco avatar Dec 03 '15 14:12 vjekofalco

We had a developer affected with this issue as well downgrading cordova from 5.4.1 to 5.4.0 npm uninstall -g cordova && npm install -g [email protected] fixed this issue for us.

cigoe avatar Dec 11 '15 15:12 cigoe

I am also facing this error.

:generateDebugSources UP-TO-DATE :compileDebugJava UP-TO-DATE :preDexDebug UP-TO-DATE :dexDebug UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':dexDebug'.

    com.android.ide.common.internal.LoggedErrorException: Failed to run command: /home/hassan/android-sdks/build-tools/22.0.1/dx --dex --no-optimize --output /var/www/moobara/app/platforms/android/build/intermediates/dex/debug --input-list=/var/www/moobara/app/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt Error Code: 2 Output:

    UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 20.936 secs

/var/www/moobara/app/platforms/android/cordova/node_modules/q/q.js:126 throw e; ^ Error code 1 for command: /var/www/moobara/app/platforms/android/gradlew with args: cdvBuildDebug,-b,/var/www/moobara/app/platforms/android/build.gradle,-Dorg.gradle.daemon=true ERROR building one of the platforms: Error: /var/www/moobara/app/platforms/android/cordova/build: Command failed with exit code 1 You may not have the required environment or OS to build this project Error: /var/www/moobara/app/platforms/android/cordova/build: Command failed with exit code 1

imhassan avatar Dec 18 '15 12:12 imhassan

Try to upload your npm on latest version. Or try to install new node. That work for me. If you are using some plugins that are using native device functionalities try to build with: "cordova prepare && cordova build --device"

2015-12-18 13:22 GMT+01:00 Hassan Siddique [email protected]:

I am also facing this error.

:generateDebugSources UP-TO-DATE :compileDebugJava UP-TO-DATE :preDexDebug UP-TO-DATE :dexDebug UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /home/hassan/android-sdks/build-tools/22.0.1/dx --dex --no-optimize --output /var/www/moobara/app/platforms/android/build/intermediates/dex/debug --input-list=/var/www/moobara/app/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt Error Code: 2 Output:

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 20.936 secs

/var/www/moobara/app/platforms/android/cordova/node_modules/q/q.js:126 throw e; ^ Error code 1 for command: /var/www/moobara/app/platforms/android/gradlew with args: cdvBuildDebug,-b,/var/www/moobara/app/platforms/android/build.gradle,-Dorg.gradle.daemon=true ERROR building one of the platforms: Error: /var/www/moobara/app/platforms/android/cordova/build: Command failed with exit code 1 You may not have the required environment or OS to build this project Error: /var/www/moobara/app/platforms/android/cordova/build: Command failed with exit code 1

— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic-cli/issues/282#issuecomment-165766591.

vjekofalco avatar Dec 18 '15 12:12 vjekofalco

The error is in PushPlugin that I am using with Cordova 5.4.1(latest). When I remove this plugin build works fine.

Cordova version is "5.4.1"

https://github.com/phonegap-build/PushPlugin

imhassan avatar Dec 18 '15 13:12 imhassan

@pmusaraj +1

MHerszak avatar Mar 02 '16 08:03 MHerszak

Hey all, this error code seems to be quite varied in cause and while I agree the error is vague (not sure if it's improved since this issue was first opened) it doesn't seem to be Ionic related, in that there is no code for us to change, so I'm going to close it.

If you come across this issue, please check on the forums: https://forum.ionicframework.com/ as you will most likely get a faster response and it will benefit everyone, thanks!

tlancina avatar Mar 02 '16 17:03 tlancina