科尔多瓦未能建立项目

时间:2015-10-17 08:36:15

标签: android cordova build compiler-errors

更新:新读者,请查看我的上次编辑。

更新cordova后,无法执行/运行

Mac-mini-de-Toni:funcook toniweb$ sudo cordova build
Password:
Running command: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/build 
ANDROID_HOME=/usr/local/Cellar/android-sdk/22.6.2
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/gradlew cdvBuildDebug -b /Users/toniweb/Proyectos/cordova/funcook/platforms/android/build.gradle -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find any version that matches com.android.support:support-v4:+.
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
         https://repo1.maven.org/maven2/com/android/support/support-v4/
     Required by:
         :android:unspecified

* 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: 9.374 secs

/Users/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/toniweb/Proyectos/cordova/funcook/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/toniweb/Proyectos/cordova/funcook/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:139:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)

我检查了我在project.properties

中设置了目标22
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-22
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:+

知道我错过了什么吗? (这在更新cordova之前工作正常)

-UPDATE -

插件:

Mac-mini-de-Toni:funcook toniweb$ cordova plugins list
org.apache.cordova.camera 0.3.6 "Camera"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.file 1.3.3 "File"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.media 0.2.16 "Media"
org.apache.cordova.media-capture 0.3.6 "Capture"

cordova平台更新android:

Mac-mini-de-Toni:funcook toniweb$ cordova platform update android
Updating android project...
cp: copyFileSync: could not write to dest file (code=EACCES):/Users/toniweb/Proyectos/cordova/funcook/platforms/android/assets/www/cordova.js

ls: no such file or directory: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/libs/cordova-*.jar

Android project updated with cordova-android@4.1.1

版本:

Mac-mini-de-Toni:funcook toniweb$ npm version
{ http_parser: '1.0',
  node: '0.10.28',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.27',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1g',
  npm: '1.4.9' }




Mac-mini-de-Toni:funcook toniweb$ node --version
v0.10.28



Mac-mini-de-Toni:funcook toniweb$ cordova -v
5.3.3

而且:

android list sdk

会提示我进入java的下载页面,我安装并重新启动,仍然提示我一样

No Java runtime present, requesting install. No Java runtime present, requesting install.

- 编辑 -

通过安装jdk,这最后的事情不再发生了

- 编辑 -

通过安装jdk,我可以构建并运行cordova android,只有当我使用sudo否则看起来像是同样的错误

3 个答案:

答案 0 :(得分:1)

您的问题似乎未安装Android支持存储库,Android支持库和Google存储库,或者已过期,请安装/更新它们并重试。 TACO不会更新它们,因此请尝试手动执行

OLD: 您可以做的最好的事情是安装Microsoft TACO

npm install -g taco-cli
taco create myAwesomeApp
cd myAwesomeApp
taco platform add android
taco install-reqs android
taco build android

重要命令是taco install-reqs android,它应该安装Android开发所需的全部内容或修复您可能遇到的任何问题

如果您不想使用TACO,您的问题似乎是Android安装支持存储库,Android支持库和Google存储库未安装或已过期,请安装/更新它们并重试。

答案 1 :(得分:0)

由于您已经运行了cordova 5.3.3,因此当您将插件更新到当前版本时,可能会摆脱构建错误。 cordova项目有moved all official plugins to the NPM Registry

我不知道" com.android.support的确切问题:support-v4问题"但是由于这个支持库,我也遇到了几个插件构建问题。

您也可以尝试install this Plugin来解决问题。

this (nearly duplicate) Question中的一个答案建议更新Android SDK(好主意)并删除并添加Android平台(如果你在android文件夹中有自定义并且没有备份它们,那就是个坏主意)

答案 2 :(得分:-1)

遇到相同类型的错误,但命令行中的android list sdk给了我Packages available for installation or update: 10 1- GPU Debugging tools, revision 1.0.3 2- Local Maven repository for Support Libraries, revision 28 3- Android Auto Desktop Head Unit emulator, revision 1.1 4- Google Play services, revision 29 5- Google Repository, revision 25 6- Google Play APK Expansion Library, revision 3 7- Google Play Billing Library, revision 5 8- Google Play Licensing Library, revision 2 9- Android Auto API Simulators, revision 1 10- Google Web Driver, revision 2

更新android sdk解决了我的问题 使用命令在我的系统中更新了以下内容 android update sdk --no-ui --filter 1,2,5,6,7,8,9 或者您可以尝试更新所有包