Cordova:未指定buildToolsVersion(MacOS) [英] Cordova: buildToolsVersion is not specified (MacOS)

查看:237
本文介绍了Cordova:未指定buildToolsVersion(MacOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 cordova build android --release

Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.

似乎未指定buildToolsVersion。

it seems like buildToolsVersion is not specified.

这是cordova使用的Android_Home。

Here is the Android_Home which is used by cordova.

ANDROID_HOME=/usr/local/Caskroom/android-platform-tools/latest

基本上我正在尝试使用以下方式更改此路径,但它并未更改cordova中的路径

basically i am trying to change this path with below but it is not changing the path in cordova build.

我正在使用以下命令更改路径。

I am using below command to change the path.

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中的路径。

but it is not changing the path in Cordova.

请告知。

编辑:我也尝试删除并添加

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

Edit2 If i use the same terminal then path of android_home is changed. Seems like bashrc is not updating.

但是现在我遇到了另一个错误,构建失败了。

But now i am getting different error and build getting failed.

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

我已经安装了SDK构建工具版本19.1.0、23.0.1和26.0,但我仍然

I have installed sdk build tool version 19.1.0, 23.0.1 and 26.0 but still i am getting the error.

编辑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路径如下。

Edit4 Now my android and java path are below.

ANDROID_HOME=/Users/admin/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home

当我运行cordova构建android i

When i run cordova build android i am getting below error.

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.


推荐答案

查看 Cordova Android GitHub存储库 在其中搜索 buildToolsVersion ,您会看到 build.gradle Android buildToolsVersion 当前设置为 23.0.1

Looking at the Cordova Android GitHub repo and searching it for buildToolsVersion, you'll see in build.gradle the Android buildToolsVersion is currently set for 23.0.1

单击上面的搜索链接,然后尝试安装为文件 build.gradle

Click on the search link above, and try installing the Android Build Tools version shown for the file build.gradle.

这篇关于Cordova:未指定buildToolsVersion(MacOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆