简体   繁体   中英

How do I determine which Android Gradle Plugin version is needed for my target SDK?

I am trying to sync my project with the Gradle files but every time I do it I get the same error message:

WARNING: The specified Android SDK Build Tools version (27.0.0) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.

My target SDK version is API 24 since I am developing an app for an Android 7.0 (Nougat) operating system.

I looked over the Android Developers site: https://developer.android.com/ and I can't find anything about what Android Gradle Plugin corresponds with which target SDK version. I've read several Stack Overflow questions where people asked about which specific Android Gradle Plugin they need for their project but none of the questions were about where to go to find that information.

Can anyone tell me how to know which Android Gradle plugin version I need?

Here are the two build.gradle files in my app folder:

(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '27.0.0'

    defaultConfig {
        applicationId "com.android.example.favoritetoys"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            debuggable true
    }
        debug {
            applicationIdSuffix ".debug"
            debuggable true
        }
    }

}

(Project)

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

allprojects {
    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.contains("windows")) {
        buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    }
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Since AGP (Android Gradle Plugin) version 3.0.0, there is a minimum version requirement for the Android Build Tools version, which is a designed behaviour.

See http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.AppExtension.html#com.android.build.gradle.AppExtension:buildToolsVersion

So, if you want to force your project to use an older version of build tools, i am afraid that you need to downgrade your AGP to a version below 3.0.0.

But, question for you is why do have to use the older build tools?

As seen from https://developer.android.com/studio/releases/build-tools .

You should always keep your Build Tools component updated by downloading the latest version using the Android SDK Manager.

For your cross reference about the differences among the three different version configurations in build.gradle , ie compileSdkVersion , targetSdkVersion and minSdkVersion .

For your case, maybe you only need to change your targetSdkVersion to 28 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM