I am currently using Android Studio 3.3 Canary 11 with gradle plugin version 3.3.0-alpha11, and I encounter a deprecation warning during the gradle sync process:
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete. The recommended alternative is 'variant.getExternalNativeBuildProviders()'. This will be completely removed after 2019.
Affected Modules: app
This warning relates to the following code snippet in my app module’s build.gradle file:
applicationVariants.all { buildVariant ->
buildVariant.outputs.all {
outputFileName = "${buildVariant.name}-${buildVariant.versionName}.apk"
}
}
I’m a bit confused about what changes I should implement here. As this code seems to just handle APK file naming, I’m unsure why it’s causing the deprecation warning.
As for my project level build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
classpath "io.realm:realm-gradle-plugin:4.1.1"
classpath 'com.google.gms:google-services:3.2.1'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
minSdkVersion = 21
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '27.0.3'
supportLibraryVersion = '27.1.1'
appCompactLibraryVersion = '27.1.1'
playServicesVersion = '15.0.1'
firebaseVersionCore = '16.0.1'
firebaseVersionPerf = '16.0.0'
firebaseVersionMessaging = '17.1.0'
lottieVersion = '2.5.0'
}
And here is my app module’s build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
android {
realm {
syncEnabled = false
}
dexOptions {
javaMaxHeapSize "4g"
}
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.myapp.example"
minSdkVersion rootProject.ext.minSdkVersion
multiDexEnabled true
versionCode appVersionCode
versionName appVersionName
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
applicationVariants.all { buildVariant ->
buildVariant.outputs.all {
outputFileName = "${buildVariant.name}-${buildVariant.versionName}.apk"
}
}
release {
shrinkResources true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
}
}
debug {
shrinkResources true
minifyEnabled true
useProguard true
debuggable true
versionNameSuffix '-DEBUG'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'debug-proguard-rules.pro'
ext.enableCrashlytics = false
crunchPngs false
}
}
flavorDimensions "default"
lintOptions {
checkReleaseBuilds false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LGPL2.1'
}
buildToolsVersion '28.0.2'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$rootProject.appCompactLibraryVersion"
implementation "com.android.support:support-compat:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
api 'com.squareup.retrofit2:retrofit:2.4.0'
api 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.firebase:firebase-core:$rootProject.firebaseVersionCore"
implementation "com.google.firebase:firebase-perf:$rootProject.firebaseVersionPerf"
implementation "com.google.firebase:firebase-messaging:$rootProject.firebaseVersionMessaging"
api('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
I would appreciate detailed guidance on the necessary adjustments to eliminate this deprecation warning.