Cordova Android Build Failure

时间:2015-06-02 17:37:01

标签: android cordova

我正在尝试在Mac OS X Yosemite上构建基本的Cordova v5.0 Android v4.0项目,但不断收到此错误。注意:在Cordova v4上构建相同的过程。我已经卸载并重新安装了Android SDK,Cordova,甚至是Gradle(但我认为我不需要它)。我检查过我的Path变量包含/ tools和/ platform_tools的正确路径。但是,当我做“科尔多瓦”的建设时,或者&#cord; build cord'我总是得到同样的错误:

  

无法创建类型的实例   org.gradle.invocation.DefaultGradle_Decorated。

进一步向下说:

  

您可能没有构建此项目所需的环境或操作系统

我错过了什么?

这是我正在做的全文:

my_acct$cordova create build_test com.example.build_test "BuildTest"
Creating a new cordova project.
my_acct$cd build_test
my_acct$cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: com.example.build_test
    Name: BuildTest
    Activity: MainActivity
    Android target: android-22
Copying template files...
Android project created with cordova-android@4.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist@1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 304 https://registry.npmjs.org/cordova-plugin-whitelist
Installing "cordova-plugin-whitelist" for android
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build 
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/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/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131: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)

如果我更改为使用java 1.7或1.8,则错误更改为:

  

配置根项目' android'。

时出现问题      
    

无法解析配置':classpath'的所有依赖项。     无法解决com.android.tools.build:gradle:1.0.0+。          要求:              :安卓:不详     org.slf4j.spi.LocationAwareLogger.log(Lorg / SLF4J /标记; Ljava /郎/字符串; ILjava /郎/字符串; [Ljava /郎/对象; Ljava /郎/ Throwable的;)V

  

以下是使用java 1.7或1.8的完整结果:

my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build 
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/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 ':classpath'.
   > Could not resolve com.android.tools.build:gradle:1.0.0+.
     Required by:
         :android:unspecified
      > org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

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

/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/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/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131: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)

2 个答案:

答案 0 :(得分:0)

我明白了。我在〜/ Library / Java / Extensions中找到了旧的,有冲突的.jar文件。吹掉整个〜/ Library / Java目录。 Cordova(和Android Studio)现在运行得很好。

答案 1 :(得分:0)

解决此问题的另一种方法是从

更改存储库
mavenCentral() 

maven{
   url 'https://repo1.maven.org/maven2'
}
platforms / android / build.gradle platforms / android / CordovaLib / build.gradle

中的

相关问题