【发布时间】:2017-12-07 01:55:26
【问题描述】:
我在运行cordova build android --release时遇到错误
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
好像没有指定 buildToolsVersion。
这是 Cordova 使用的 Android_Home。
ANDROID_HOME=/usr/local/Caskroom/android-platform-tools/latest
基本上我正在尝试用下面的方式更改此路径,但它不会更改 Cordova 构建中的路径。
我正在使用以下命令来更改路径。
export ANDROID_HOME=/Users/admin/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
source .bash_profile
echo $ANDROID_HOME
但它不会改变 Cordova 中的路径。
编辑:我还尝试在 Cordova 中删除和添加 android 平台。
编辑 2: 如果我使用相同的终端,则 android_home 的路径会更改。好像 bashrc 没有更新。
但是现在我遇到了不同的错误并且构建失败了。
platforms/android/src/org/apache/cordova/file/FileUtils.java:15: error: <identifier> expected
我已经安装了 sdk build tool 版本 19.1.0、23.0.1 和 26.0,但仍然出现错误。
编辑 3:build.gradle
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
jcenter()
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
mavenCentral();
jcenter()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}
// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
apply from: 'CordovaLib/cordova.gradle'
// The value for android.compileSdkVersion.
if (!project.hasProperty('cdvCompileSdkVersion')) {
cdvCompileSdkVersion = null;
}
编辑 4:现在我的 Android 和 Java 路径如下。
ANDROID_HOME=/Users/admin/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
当我运行 cordova build android 时,我遇到了错误。
com.sun.tools.javac.parser.JavacParser.classOrInterfaceOrEnumDeclaration(JavacParser.java:3226)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
【问题讨论】: