346

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.

11
  • Can you post your build.gradle(app)? Sep 19, 2018 at 18:31
  • @Skizo-ozᴉʞS added the project build.gradle file Sep 19, 2018 at 18:36
  • @alashow this is related to different issue, message there is "API 'variant.getJavaCompile()' is obsolete.." Dec 20, 2018 at 10:16
  • 16
    Issue exists with the stable version as well
    – kp91
    Jan 15, 2019 at 6:40

21 Answers 21

293

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

6
249

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.

17
  • 2
    Would it be possible for you to link to the bug report or issue you opened with Firebase? I'd love to upvote it.
    – yuval
    Jan 15, 2019 at 0:00
  • 8
    I have to use the io.fabric plugin then how can i remove this warning without changing this?
    – 0xAliHn
    Jan 16, 2019 at 13:57
  • 16
    This is the cause, not a viable solution Jan 17, 2019 at 8:45
  • 1
    They are saying that you can use it until end of the 2019 year. For now I'm using, we will see what happens )
    – support_ms
    Jan 21, 2019 at 1:29
  • 4
    Why downgrading? No sense! It's just a warning, it's not removed yet and it can build your project (the whole 2019 year...). I believe they will fix it during this year
    – user25
    Jan 25, 2019 at 10:33
61

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

6
  • 2
    Then you also have to downgrade to Android Studio 3.2.1. Thanks anyway Jan 15, 2019 at 11:15
  • I had the same problem after upgrading Android Studio (AS) to version 3.3. I got Gradle sync to work again by downgrading Gradle to version 4.6 and Android Gradle Plugin to version 3.2.1, which was the versions I was using prior to the AS update. Look up the table here if you are doubt how to modify the versions for gradle and the plugin. Jan 15, 2019 at 12:57
  • 6
    It worked without downgrading anything thanks for the suggestion
    – Sid
    Jan 15, 2019 at 19:28
  • 3
    you don't need to downgrade your android studio @RubénViguera Jan 23, 2019 at 21:02
  • 1
    You don't need to downgrade anything other than gradle version as mentioned in the answer. This should be the accepted answer. Feb 23, 2019 at 7:14
17

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+

3
  • @RJB Are you using Crashlytics? If you remove it from your project it works ? If yes then this should fix the issue. However you might still get warnings, but the project will compila and you can generate your apk safely
    – 113408
    Jan 18, 2019 at 7:50
  • Yes. I mean that I am still getting the warning.
    – RJB
    Jan 18, 2019 at 7:55
  • the op and others (including me) had this issue and were unable to compile the project with crashlytics enabled. So to keep Crashlytics and still push to prod you can use the above mentioned update even though it still trigger "warnings".
    – 113408
    Jan 18, 2019 at 15:20
14

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

12

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] #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 :)

0
9

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
    }
5
  • How about we just add -dontwarn com.crashlytics.android.Crashlytics in proguard-rules.pro
    – Mustansir
    Feb 9, 2019 at 8:28
  • 1
    If you remove the warning by doing that the problem is still there and you will need to eventually get back to the problem again Feb 9, 2019 at 15:59
  • Right! It is a temp solution to get build compiled, but it is much better than downgrading everything.
    – Mustansir
    Feb 10, 2019 at 4:37
  • Yes, downgrading it will cause to work, if you dismiss the warning you can keep the updated version but it won't work Feb 10, 2019 at 7:31
  • @Mustansir, I think it's a gradle-related problem and has nothing to do with Proguard.
    – WindRider
    Mar 9, 2019 at 16:18
5

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

4

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.

6
  • Yes, i agree, this type of error was not present in the previous build tools. The next RC may fix it
    – d4c0d312
    Oct 25, 2018 at 23:42
  • 7
    it was not fixed in the release
    – Juan Diaz
    Jan 15, 2019 at 4:35
  • developer.android.com/studio/releases/gradle-plugin#3-3-0 ...add android.debug.obsoleteApi=true to see where it comes from. there were a few methods renamed, with Provider appended to their name. Jan 15, 2019 at 18:25
  • 1
    @SergeyNarozhnyy in project gradle.properties
    – sigitbn
    Jan 17, 2019 at 22:27
  • 1
    @SergeyNarozhnyy the 3.3.0 release broken a few things, since the variant API had changed. can link one recent discussion: stackoverflow.com/questions/54206898/… (added a summary as an answer there). Jan 18, 2019 at 0:29
4

For me, I followed these steps: 1. upgrade the Gradle dependency on project level build.gradle.

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

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

2

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

3
  • 1
    Thanks. Your answer helped me. Feb 14, 2019 at 22:31
  • @Sean If you are using Kotlin and io febric.then It works otherwise for working downgrade your classpath version.It will works... Feb 27, 2019 at 5:34
  • The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration Mar 12, 2019 at 10:14
1

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.

1

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'**
}
0

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

0

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

2
  • In top level build.gradle or module level (/app) ? Feb 22, 2019 at 6:09
  • module level(app) Sep 3, 2019 at 18:38
0

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

0

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'
0
0

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.

0

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'
    }
}
0

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'
}
-7

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'

Not the answer you're looking for? Browse other questions tagged or ask your own question.