Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving a build error when upgrading to gradle 3.3 and android build tools 2.3.0

I just updated my build files

Gradle from 2.14.1 to 3.3 Android Plugin from 2.2.3 to 2.3.0

I am receiving the following error. Seems like some thirdparty plugin issue. Can anyone shed light to it? I cant find anything in change logs related to this change.

A problem occurred configuring project ':apis'.

Failed to notify project evaluation listener.

The "android" command is no longer included in the SDK. Any references to it (e.g. by third-party plugins) should be removed.

The build file in which error is thrown looks something like this

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.library'
apply plugin: 'android-apt'

android {
  compileSdkVersion Integer.parseInt(ANDROID_SDK_VERSION)
  buildToolsVersion ANDROID_BUILD_TOOLS_VERSION

  // Legacy apache network stack
  useLibrary 'org.apache.http.legacy'

  defaultConfig {
    minSdkVersion Integer.parseInt(ANDROID_MIN_SDK_VERSION)
    targetSdkVersion Integer.parseInt(ANDROID_SDK_VERSION)
    consumerProguardFiles 'proguard-rules.pro'
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
  }

  packagingOptions {
    exclude 'LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE'
  }

  lintOptions {
    abortOnError false
  }
}

...
like image 979
JehandadK Avatar asked Mar 03 '17 05:03

JehandadK


People also ask

How do I update my project level build Gradle to latest version?

You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line. The preferred way is to use the Gradle Wrapper command line tool, which updates the gradlew scripts.

How do I change the build tools version?

The Build Tools version of your project is (by default) specified in a build. gradle file, most likely in the app sub directory. Open the file and change/specify the Build Tools version you want to use by adding/changing a buildToolsVersion property to the android section: android { buildToolsVersion "24.0.

What is COM Android tools build Gradle for?

As the name suggest, "Android Build Tools" is a command line tools for building your Java source code (along with all the related assets) into executable APK file.


2 Answers

android-apt has been deprecated and, as per the migration guide:

As of the Android Gradle plugin version 2.2, all functionality that was previously provided by android-apt is now available in the Android plugin.

You can remove android-apt and follow the migration guide to get the equivalent functionality.

Similarly, as per the sdk-manager-plugin page:

This plugin is deprecated and is no longer being developed. Tools and dependencies are automatically downloaded using version 2.2.0 of the Android Gradle plugin or newer.

So it too can be removed.

like image 163
ianhanniballake Avatar answered Sep 27 '22 21:09

ianhanniballake


Want to summarize what it take for us to upgrade:

  1. Upgrade to gradle 3.3 and android build tools 2.3.0

    -classpath 'com.android.tools.build:gradle:2.2.3'
    +classpath 'com.android.tools.build:gradle:2.3.0'
    

    and

    -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
    +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
    

    These should be done by Android Studio automatically when you upgrade.

  2. Remove android-apt and sdk-manager-plugin as suggested by @ian

    -classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    

    and

    -apply plugin: 'android-sdk-manager'
    -apply plugin: 'com.neenbedankt.android-apt'
    

    These plugins are deprecated and no longer needed in newer version of gradle.

  3. Change the build tool version number in the app/build.gradle file:

    -  buildToolsVersion "23.0.3"
    +  buildToolsVersion '25.0.0'
    
  4. Search for all apt in the gradle file and replace with annotationProcessor. As an example, we are using AutoValue and Parceler and we'll have to do these:

    -  apt "com.ryanharter.auto.value:auto-value-gson:$autoValueGsonVersion"
    +  annotationProcessor "com.ryanharter.auto.value:auto-value-gson:$autoValueGsonVersion"
    

    and

    -  apt "org.parceler:parceler:$parcelerVersion"
    +  annotationProcessor "org.parceler:parceler:$parcelerVersion"
    
  5. Finally, which is also important, clean and rebuild.

like image 36
Yuchen Avatar answered Sep 27 '22 20:09

Yuchen