简体   繁体   中英

cordova-android ./create $( which android ) exited with a 1

After executing the command to create a project...

./create <PATH_TO_PROJECT_DIR> <COM_PATH> <PROJECT_NAME>

I get the error message:

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

Troubleshooting responses: (acconrad provided a smart checklist here for solving Cordova errors...)

Did you download the correct version of PhoneGap from the correct LOCATION? It appears as if there are versions of PhoneGap that do not come packaged with Cordova-2.x.0.jar, which is necessary to run the script. Download here to obtain PhoneGap with the correct JAR file.

I have followed the instructions at the official Apache Cordova API Documentation site and downloaded the cordova-android repository from github . The official documentation does not say anything about this jar file and as such I have not executed it.

Did you already create the folder? The documentation claims that you can use this command as long as the new folder is blank. This is not true. Make sure the folder does not exist before attempting to create the project.

Fresh folder path, never created.

Do you have the latest version of Ant? You will need Ant 1.8.0 or greater to run PhoneGap with Android. Use ant -v to verify your version.

Ant version 1.8.2, although running the -v flag pops up the following output...

Apache Ant(TM) version 1.8.2 compiled on June 3 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

...as if it was trying to build. I assume -v means verbose and ant is trying to build the current director, in which there is no build.xml file, because I'm not building a project with ant, merely finding the version, which is 1.8.2.

Is your .bash_profile/Environment Varibles PATH set properly? The official documentation has been updated to reflect this, but you will absolutely need these variables set correctly in order to create the project.

Both SDK paths have been set & source d.

Did you update the terminal to reflect your new PATHs? source .bash_profile or . .bash_profile in your currently open terminal window so your paths are updated when running the create command.

Haven't restarted but $PATH outputs the correct android-sdk-macosx paths (platform-tools && tools).

Do you have the correct commons-codec? You may receive an accompanying error referring to a missing commons-codec file, which you can download here.

No commons-codec accompanying error is being displayed.

The problem was indeed the PATH variables...

/PATH/TO/android-sdk-maxosx/platform-tools

/PATH/TO/android-sdk-maxosx/tools

removed the macosx from the path name.

Correcting these environment variables in ~/.bash_profile solved this problem.

You should modifying the PATH Environment Variable:

For Ubuntu: $ nano ~/.bashrc

You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:

#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

https://help.ubuntu.com/community/AndroidSDK

For Mac OS:

look in your home directory for .bash_profile. Create the .bash_profile file if you don't have one. Look for the PATH environment variable and add the full path to the tools/ directory to the PATH. If you don't see a line setting the PATH, you can add one: export PATH=${PATH}:/tools

https://sites.google.com/site/richgossweiler/home/android-development-notes/installing-the-android-sdk-on-the-mac-os-x

This also happens if the name of the COM_PATH contains an invalid character or does not have 3 namespaces like:

com.example.project

This is probably because of a wrong PATH. You should edit environment variables in ~/.bash_profile. Refer this Blog post for a detailed explanation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM