cordova指定版本_android-Cordova:未指定buildToolsVersion(MacOS)

桂宏旷
2023-12-01

我在运行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中删除并添加android平台.

EDIT2

如果我使用相同的终端,则android_home的路径将更改.好像bashrc没有更新.

但是现在我遇到了不同的错误,构建失败了.

platforms/android/src/org/apache/cordova/file/FileUtils.java:15: error: expected

我已经安装了SDK构建工具版本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;

}

Edit4

现在我的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.

 类似资料: