一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Android开发之PhoneGap打包及错误解决办法

时间:2014-07-25 编辑:简简单单 来源:一聚教程网


在我安装、配置好PhoneGap项目的所有依赖后,试图执行

$ cordova run android

命令时,出现过如下错误。


Error: /home/sam/front/redwine/platforms/android/cordova/run: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
view rawphonegapError hosted with ❤ by GitHub
cordova build android或cordova emulate android的结果也是一样。


但其实真正的问题在上面几行:

[aapt]     (skipping file '.jshintrc' due to ANDROID_AAPT_IGNORE pattern '.*')
     [aapt]     (skipping file '.bower.json' due to ANDROID_AAPT_IGNORE pattern '.*')
     [aapt]     (skipping file '.directory' due to ANDROID_AAPT_IGNORE pattern '.*')
     [aapt]       Unable to add '/home/sam/front/redwine/platforms/android/assets/www/bower_components/jquery-mobile/node_modules/grunt-bowercopy/node_modules/bower/node_modules/semver/semver.browser.js.gz': file already in archive (try '-u'?)
     [aapt] ERROR: unable to process assets while packaging '/home/sam/front/redwine/platforms/android/ant-build/wine.ap_'
     [aapt] ERROR: packaging of '/home/sam/front/redwine/platforms/android/ant-build/wine.ap_' failed
 
BUILD FAILED
/home/sam/bin/android-sdk-linux/tools/ant/build.xml:932: The following error occurred while executing this line:
/home/sam/bin/android-sdk-linux/tools/ant/build.xml:950: null returned: 1
view rawphonegapError2 hosted with ❤ by GitHub

这是因为项目下有多个node_modules目录,被重复打包而引发的Command failed with exit code 8问题。


解决办法是修改platforms/android/build.xml:

将node_modules目录排除掉,就可以正常执行cordova命令。

热门栏目