API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()

AndroidFirebaseAndroid StudioAndroid Gradle-Pluginfabric.io

Android Problem Overview


Using Android Studio 3.3 Canary 11 with the gradle plugin version 3.3.0-alpha11. It throws the following error when trying to sync gradle

WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been 
replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration- 
avoidance
Affected Modules: app

Clicking on the error leads me to this line in the gradle file

applicationVariants.all { variant ->
            variant.outputs.all {
                outputFileName = "${variant.name}-${variant.versionName}.apk"
            }
        }

What exactly do I need to change here?

project build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
	repositories {
		jcenter()
		mavenCentral() // jcenter() works as well because it pulls from Maven Central
		maven { url "https://maven.google.com" }
		google()
	}

	dependencies {
		classpath 'com.android.tools.build:gradle:3.3.0-alpha11'

		// NOTE: Do not place your application dependencies here; they belong
		// in the individual module build.gradle files
		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()
		maven { url "https://maven.google.com" }
	}
}

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

// Define versions in a single place
ext {
	// Sdk and tools
	minSdkVersion = 21
	targetSdkVersion = 27
	compileSdkVersion = 27
	buildToolsVersion = '27.0.3'

	// App dependencies
	supportLibraryVersion = '27.1.1'
	appCompactLibraryVersion = '27.1.1'
	playServicesVersion = '15.0.1'
	firebaseVersionCore = '16.0.1'
	firebaseVersionPerf = '16.0.0'
	firebaseVersionMessaging = '17.1.0'

	//lottie
	lottieVersion = '2.5.0'
}

app build.gradle

buildscript {
	repositories {
		maven { url 'https://maven.fabric.io/public' }
	}

	dependencies {
		classpath 'io.fabric.tools:gradle:1.25.4'
	}
	buildscript {
		repositories {
			maven { url "https://maven.google.com" }
			maven { url 'https://maven.fabric.io/public' }
			mavenCentral()

		}

		dependencies {
			// These docs use an open ended version so that our plugin
			// can be updated quickly in response to Android tooling updates

			// We recommend changing it to the latest version from our changelog:
			// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
			classpath 'io.fabric.tools:gradle:'
		}
	}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
repositories {
	maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'io.fabric'
apply plugin: 'realm-android'

android {

	realm {
		syncEnabled = false
	}

	dexOptions {
		javaMaxHeapSize "4g"
	}

	compileSdkVersion rootProject.ext.compileSdkVersion

	defaultConfig {
		applicationId "example.com"
		minSdkVersion rootProject.ext.minSdkVersion
		multiDexEnabled true
		versionCode mVersionCode
		versionName mVersionName
		vectorDrawables.useSupportLibrary = true

	}

	compileOptions {
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
	}

	buildTypes {

		applicationVariants.all { variant ->
			variant.outputs.all {
				outputFileName = "${variant.name}-${variant.versionName}.apk"
			}
		}

		release {
			shrinkResources true
			minifyEnabled true
			useProguard true
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

			lintOptions {
				disable 'MissingTranslation'
			}

			applicationVariants.all { variant ->
				variant.outputs.all {
					outputFileName = "${variant.name}-${variant.versionName}.apk"
				}
			}

		}
		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/notice.txt'
		exclude 'META-INF/license.txt'
		exclude 'META-INF/dependencies.txt'
		exclude 'META-INF/LGPL2.1'
	}
	buildToolsVersion '28.0.2'
}

configurations {
	implementation.exclude group: "org.apache.httpcomponents", module: "httpclient"
}

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:mediarouter-v7:$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'
	api 'com.squareup.okhttp3:logging-interceptor:3.10.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.squareup.retrofit2:adapter-rxjava:2.3.0'
	implementation 'com.android.support:multidex:1.0.3'
	implementation 'com.daimajia.easing:library:2.0@aar'
	implementation 'com.daimajia.androidanimations:library:2.3@aar'

	implementation 'com.akexorcist:googledirectionlibrary:1.0.5'
	implementation 'io.reactivex:rxandroid:1.2.1'
	implementation 'io.reactivex:rxjava:1.3.0'
	// Wifi hotspot library
	implementation 'cc.mvdan.accesspoint:library:0.2.0'
	implementation 'com.android.support.constraint:constraint-layout:1.1.3'
	implementation 'org.jsoup:jsoup:1.10.3'
	api "com.airbnb.android:lottie:$rootProject.lottieVersion"
	implementation 'com.android.support:support-v4:27.1.1'
	implementation 'com.android.support:recyclerview-v7:27.1.1'
	testImplementation 'junit:junit:4.12'
	implementation 'com.jakewharton:butterknife:8.8.1'

	debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
	releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

	implementation 'com.googlecode.libphonenumber:libphonenumber:8.2.0'

	implementation "com.google.android.gms:play-services-base:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-cast-framework:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-auth:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-identity:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-awareness:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-cast:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-drive:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
	implementation "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"

	implementation "com.google.firebase:firebase-core:$rootProject.firebaseVersionCore"
	implementation "com.google.firebase:firebase-perf:$rootProject.firebaseVersionPerf"
	implementation "com.google.firebase:firebase-messaging:$rootProject.firebaseVersionMessaging"
	implementation "com.google.firebase:firebase-analytics:$rootProject.firebaseVersionCore"


	api('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
		transitive = true
	}
	api('com.crashlytics.sdk.android:answers:1.4.1@aar') {
		transitive = true
	}
	annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
	api project(path: ':libraryBTHelper')
	api project(':bkk_rush')

	debugApi 'com.amitshekhar.android:debug-db:1.0.3'
	api "org.jdeferred:jdeferred-android-aar:1.2.6"
	implementation 'com.android.support:gridlayout-v7:27.1.1'
}

apply plugin: 'com.google.gms.google-services'

I have skipped out a few constants and other sensitive information in the app/build.gradle file.

Android Solutions


Solution 1 - Android

The issue has been fixed in their latest release 'io.fabric.tools:gradle:1.30.0'

Please update your both gradle fabric tools with 1.30.0

buildscript {
  // ... repositories, etc. ...
  
   dependencies {
       // ...other dependencies ...
       classpath 'io.fabric.tools:gradle:1.30.0'
   }
}

For more details https://github.com/firebase/firebase-android-sdk/issues/198#issuecomment-473435453

Solution 2 - Android

EDIT

This issue has been fixed in Fabric 1.28.0. In your build.gradle of the project level, add the following line:

classpath 'io.fabric.tools:gradle:1.28.1'

Previous Answer

It happens after I updated Android Studio to 3.3.0. apply plugin: 'io.fabric' is the cause. I have sent a bug report to Firebase team about this issue.

You have 3 options:

  • Wait until the next version of Fabric plugin is released. Check the latest version here.

  • Downgrade to Android Studio 3.2.1.

  • Comment out io.fabric plugin.

In build.gradle of your app's module:

apply plugin: 'com.android.application'
// apply plugin: 'io.fabric' <== this plugin causes the error

However, you can still build and run your projects even though this error appears. Just ignore it.

Solution 3 - Android

In application build.gradle, downgrade to this stable version of gradle:

classpath 'com.android.tools.build:gradle:3.2.1'

It happens after I updated Android Studio to 3.3, a temp solution until they fix it.


Edit: You don't need to downgrade your Android Studio

Solution 4 - Android

UPDATE As of today you can use classpath 'io.fabric.tools:gradle:1.28.0' to fix this issue !

If commenting out Crashlytics's plugin io.fabric on the app gradle file worked for you temporarily

//apply plugin: 'io.fabric'

Then upgrading your fabric gradle dependencies on the Project gradle file will permanently solve the issue:

classpath 'io.fabric.tools:gradle:1.27.0'

NB: this doesn’t remove the warnings but let you use Crashlytics with AS3.3+

Solution 5 - Android

Not sure what the actual issue is but commenting out the crashlytics related dependencies from the project solved issue.

Solution 6 - Android

It's confirmed as bug for Crashlytics and they are working on it.

https://issuetracker.google.com/issues/116408637

Quoted from Google assignee:

> [email protected] <[email protected]> #23 Jan 23, 2019 01:40AM
> Hi all, > > Thank you for your patience. > > It looks like the bug in all cases is coming from crashlytics and I've > filed a bug with them. > > I will keep you updated on the status.

For me, my debug app is working fine on my device just by running and ignoring the warning without commenting Crashlytics or Fabric. I have not try for production.

Update:

Google Issue Tracker had mark this issues as Won't Fix (Infeasible) because all the issues was from Crashlytics, and let fixes done by Crashlytics team (despite they are same Googler...).

They suggest to follow this link for Crashlytics updates:

https://github.com/firebase/firebase-android-sdk/issues/198

Note: I'm still using Android Studio 3.3 with io.fabric.tools:gradle:1.26.0 without commenting any of Craslytics and it's works fine on my debug app.

Update:

I can confirm now that it works fine on my production/release version app. How do I know it works? Because it had sent me back a crash reports -_-'

Anyway, just ignore the warning, they should fix it eventually.

Aww, just read that it had fixed with fabric 1.28.0 :)

Solution 7 - Android

Latest news from 01/24/2019

enter image description here

Info here https://issuetracker.google.com/issues/116408637

We will need to wait untill Crashlytics came up with a solution, here is GitHub issue opened

https://github.com/firebase/firebase-android-sdk/issues/198

The only way I'm using as right now to not comment io.fabric plugin is downgrading my gradle and upgrading my fabric classpath (this is working on my production app)

 dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.27.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

Solution 8 - Android

As it was said, the problem is with Fabric/Crashlytics.

apply plugin: 'io.fabric'

It's a bug on Crashlytics/Firebase side, please check the following link and see the bug' status : https://github.com/firebase/firebase-android-sdk/issues/198

Solution 9 - Android

the issue-tracker might refer to "lazy task configuration" -

that's at least what task configuration avoidance suggests.

but one possibly can prevent the access to this obsolete method of BaseVariantImpl, when variant.outputs.all won't access that method (internally) - or when checks can prevent the access; or when accessing the variant by it's name; or somehow disable the external native build tasks for the variant. also see the single-variant project sync option, which rather seems related.

or wait for build-tools 3.3.0-alpha12 or 3.3.0-beta1 ...this is not even a release candidate, therefore investing to much time might be pointless - except using it to file another bug-report.

the new quick feedback quick feedback button still looks the most promising.

Solution 10 - Android

For me, I followed these steps:

  1. upgrade the Gradle dependency on project level build.gradle.

         classpath 'io.fabric.tools:gradle:1.28.0'
    
  2. add this plugin dependency below apply plugin: 'com.android.application' in the app level build.gradle.

         apply plugin: 'io.fabric'
    
  3. Sync the project with gradle files.

Solution 11 - Android

This happens due to the update of your Android Studio from Android Studio 3.2.0 to Android Studio 3.3.0. Update Your Gradle Dependencies (Project)of IO.Fabric. Like:

classpath 'io.fabric.tools:gradle:1.27.1'

and also update your Kotlin version to

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"

This will resolve this issues. Thanks

Solution 12 - Android

this has been fixed in the latest release of the Fabric gradle plugin, 1.28.0, which went live today. Have this in your top-level build.gradle:

buildscript {
// ... repositories, etc. ...

dependencies {
    // ...other dependencies ...
    **classpath 'io.fabric.tools:gradle:1.28.0'**
}

Solution 13 - Android

Build log prints how to debug this, particularly you need to run build with -Pandroid.debug.obsoleteApi=true, that'll print stack-trace of call to deprecated API and you'll be able to figure which plugin/code calls it.

If it ends up being your code — use new Provider API (read Lazy Task Configuration doc)

If it comes from other plugin — report to them with stack-trace and warning message and maybe submit a patch. As in this case its related to io.fabric issue.

Solution 14 - Android

When I opened the project, I pressed the Run migrations button appeared on the right bottom corner from Android Studio. A migration was performed and the problem was solve without commenting out the Crashlytics dependency.

enter image description here

Solution 15 - Android

Changing source compatibility in module build.gradle file to Java 8 fixes the issue

compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}

Be sure to rebuild the project after adding those lines

Solution 16 - Android

this will fix the error : On the taskbar click Tools->Kotlin->Configure Kotlin in Project

Solution 17 - Android

In my case, I needed to use io.fabric plugin, and the solution was, to update to the latest fabric tools gradle version:

classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'io.fabric.tools:gradle:1.27.0'

Solution 18 - Android

For those who need to keep the Fabric plugin applied, the temporary solution is to go back to the previous version of the gradle at the project level.

Change the classpath version to com.android.tools.build:gradle:3.2.1.

Solution 19 - Android

It was a problem with latest gradle (in my case 3.3.2) version and Fabric.io plugin. It is now solved by the new version Users should have this in their top-level build.gradle:

buildscript {
   // ... repositories, etc. ...
   
    dependencies {
        // ...other dependencies ...
        classpath 'io.fabric.tools:gradle:1.28.0'
    }
}

Solution 20 - Android

Fix is update the root build gradle files to latest. And this answer hold true now. in fureture again new change will be implementing by gradle and android SDK. At times answer will vary in due course of time.

repositories {
    maven { url "https://jitpack.io" }
    maven {
        url 'https://maven.fabric.io/public'
    }
    google()
    jcenter()
    
}
dependencies {

    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath 'com.google.gms:google-services:4.3.0'
    classpath 'io.fabric.tools:gradle:1.30.0'
}

Solution 21 - Android

first of all this is not an error

it's warning

and its show up when update gradle to 3.3.0 Often occur because io.fabric so wait until the update fabric current version where warning is still show up is 'io.fabric.tools:gradle:1.27.1'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJude FernandesView Question on Stackoverflow
Solution 1 - Android0xAliHnView Answer on Stackoverflow
Solution 2 - AndroidAnggrayudi HView Answer on Stackoverflow
Solution 3 - AndroidAmer AlZibakView Answer on Stackoverflow
Solution 4 - Android113408View Answer on Stackoverflow
Solution 5 - AndroidJude FernandesView Answer on Stackoverflow
Solution 6 - AndroidRydeView Answer on Stackoverflow
Solution 7 - AndroidGastón SaillénView Answer on Stackoverflow
Solution 8 - AndroidAgna JirKon RxView Answer on Stackoverflow
Solution 9 - AndroidMartin ZeitlerView Answer on Stackoverflow
Solution 10 - Androidamit pandyaView Answer on Stackoverflow
Solution 11 - AndroidRahul KushwahaView Answer on Stackoverflow
Solution 12 - AndroidVladyslav PanchenkoView Answer on Stackoverflow
Solution 13 - Android0xAliHnView Answer on Stackoverflow
Solution 14 - AndroidpableirosView Answer on Stackoverflow
Solution 15 - AndroidPetarView Answer on Stackoverflow
Solution 16 - AndroidSadjad AbbasniaView Answer on Stackoverflow
Solution 17 - AndroidFragmentView Answer on Stackoverflow
Solution 18 - AndroidHenrique MonteView Answer on Stackoverflow
Solution 19 - AndroidMohammadView Answer on Stackoverflow
Solution 20 - AndroidPavanView Answer on Stackoverflow
Solution 21 - AndroidalacooView Answer on Stackoverflow