简体   繁体   中英

MacOS: cordova platform add android

I Use Yosemite, and I can't build android app with cordova phonegap

My ".bash_profile" file

$ cat ~/.bash_profile 
export ANDROID_HOME=/Users/huy/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export ANT_HOME=/usr/local/apache-ant-1.9.4

Cordova, nodejs, ant version

$ ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
$ node --version
v0.10.35
$ cordova -v
4.1.2

My Android SDK components

(sorry I can't attach photo)

Android SDK Tools           24.0.2
Android SDK Platform-tools  21
Android 4.4.2 (API 19)

I have a phonegap project at "/Users/huy/Documents/zPhoneGap/Helloworld"

then add android platform to this phonegap project

$ cd /Users/huy/Documents/zPhoneGap/Helloworld 
$ cordova platform ls
Installed platforms: ios 3.7.0
Available platforms: amazon-fireos, android, blackberry10, browser, firefoxos
$ cordova platform add android
Creating android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: io.cordova.hellocordova
    Name: HelloCordova
    Android target: android-19
Copying template files...
Project successfully created.
Installing "org.apache.cordova.battery-status" for android
Installing "org.apache.cordova.console" for android
$ cordova platform ls
Installed platforms: android 3.6.4, ios 3.7.0
Available platforms: amazon-fireos, blackberry10, browser, firefoxos

after that, I just build for android

$ cordova build android

but the result is "BUILD FAILED"

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] /Users/huy/Documents/zPhoneGap/Helloworld/platforms/android/res/xml/config.xml:34: error: Error parsing XML: unbound prefix
     [aapt] 


BUILD FAILED
/Users/huy/Library/Android/sdk/tools/ant/build.xml:653: The following error occurred while executing this line:
/Users/huy/Library/Android/sdk/tools/ant/build.xml:698: null returned: 1

Total time: 5 seconds

/Users/huy/Documents/zPhoneGap/Helloworld/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,/Users/huy/Documents/zPhoneGap/Helloworld/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/huy/Documents/zPhoneGap/Helloworld/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)

I have no idea to fix this, google around but nothing work.

Phonegap/Cordova build android node_modules/q/q.js throw e;

Cordova android build error

PhoneGap/Cordova Android Development

Anyone know why this is happening and how to resolve it? Many thanks!

我有同样的问题,但当我更改<widget id="config.xml">的值时,它可以工作。

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