Thursday, December 5, 2013

An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1 Deleting project... - PhoneGap

I was trying to create a new android project via command line in Mac and I got: "An error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1 Deleting project..."

Following was the command I used in Terminal to create a new Android PhoneGap Project. This works for iOS but not for Android.
 ./create ~/Desktop/MyPhoneGapApp com.companyname.myphonegapapp MyPhoneGapApp  
And I got an error as follows.
 An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1 Deleting project... -  
Most probably this occurs because path to "tools" and "platform-tools"of the the Android SDK is not set to the PATH.

To fix this you should open the bash profile. Enter the following command in the terminal
 open ~/.bash_profile  

Now you will see the .bash_profile opened in the Text Editor. Enter the following line to your .bash_profile, save and close the file. Make sure to edit the following code to use the correct path of yours.
 PATH=$PATH:/Users/myaccount/Documents/adt-bundle-mac-x86_64/sdk/platform-tools:/Users/myaccount/Documents/adt-bundle-mac-x86_64/sdk/tools  
You should execute your .bash_profile to update your PATH.  Enter the following command in Terminal
 source ~/.bash_profile  
Now close and reopen your Teminal. Navigate to the bin folder of Android PhoneGap and enter the following command to create a PhoneGap Android Project.
 ./create ~/Desktop/MyPhoneGapApp com.companyname.myphonegapapp MyPhoneGapApp  
Done :)

1 comment:

  1. Hi I followed you steps and it returns me this error

    An unexpected error occurred: ant jar > /dev/null exited with 127 im using cordova 2.6.0 due to legacy concerns.

    ReplyDelete