Search code examples
androidandroid-gradle-plugindeprecation-warning

buildToolsVersion and compileSdkVersion had been deprecated


I've just noticed in a library module, that compileSdkVersion and buildToolsVersion had recently been deprecated. These are the two configurations, which it complains about (strikethrough text). This currently only affects com.android.library, not com.android.application:

plugins {
    id "com.android.library"
}
android {
    defaultConfig {
        compileSdkVersion 31
        buildToolsVersion "31.0.0"
    }
}

Screenshot: build.gradle

When clicking through, one may notice that com.android.build.gradle.AndroidConfig had been deprecated in favor of BaseExtension (whatever that may mean for a matching build.gradle):

Screenshot: Fernflower


Apparently compileSdkVersion is now called compileSdk (this part seems to work) ...and buildToolsVersion has to be defined as a property. But when building (it's not that I've not tried), property buildToolsVerson = "31.0.0" is unknown:

android {
    defaultConfig {
        compileSdk 31
        buildToolsVersion = "31.0.0"
    }
}

How to make it build without deprecation warnings?


Solution

  • It builds alike this (the library module needs to be changed):

    plugins {
        id "com.android.application"
    }
    android {
        defaultConfig {
            compileSdkVersion 31
        }
    }
    
    plugins {
        id "com.android.library"
    }
    android {
        defaultConfig {
            // compileSdkVersion 31
            compileSdk 31
        }
    }