Roxx
Roxx

Reputation: 3996

Cordova: buildToolsVersion is not specified (MacOS)

I am getting below error while running cordova build android --release

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

it seems like buildToolsVersion is not specified.

Here is the Android_Home which is used by Cordova.

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

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

but it is not changing the path in Cordova.

Edit: I also tried to remove and add android platform in Cordova.

Edit 2: 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

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

Edit 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;
    }

Edit 4: 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

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.

Upvotes: 2

Views: 2897

Answers (1)

Jim Bergman
Jim Bergman

Reputation: 5237

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

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

Upvotes: 1

Related Questions