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

73,428

Solution 1

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

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

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

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

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

Share:
73,428
Jude Fernandes
Author by

Jude Fernandes

I am a partner and one of the co-founders of Octalogic Tech located in Goa. We craft beautifully designed softwares and websites along with mobile apps.

Updated on October 15, 2021

Comments

  • Jude Fernandes
    Jude Fernandes over 2 years

    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.