API'variable.getExternalNativeBuildTasks()'已过时,已替换为'variant.getExternalNativeBuildProviders()

Jud*_*des 328 android firebase android-studio android-gradle-plugin fabric.io

使用带有gradle插件版本的Android Studio 3.3 Canary 11 3.3.0-alpha11.尝试同步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
Run Code Online (Sandbox Code Playgroud)

单击错误会将我引导至gradle文件中的此行

applicationVariants.all { variant ->
            variant.outputs.all {
                outputFileName = "${variant.name}-${variant.versionName}.apk"
            }
        }
Run Code Online (Sandbox Code Playgroud)

我到底需要改变什么?

项目 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'
}
Run Code Online (Sandbox Code Playgroud)

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'
Run Code Online (Sandbox Code Playgroud)

我在app/build.gradle文件中跳过了一些常量和其他敏感信息.

0xA*_*iHn 271

该问题已在其最新版本中修复。 'io.fabric.tools:gradle:1.30.0'

请使用1.30.0更新两个Gradle Fabric工具

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

   dependencies {
       // ...other dependencies ...
       classpath 'io.fabric.tools:gradle:1.30.0'
   }
}
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息https://github.com/firebase/firebase-android-sdk/issues/198#issuecomment-473435453

  • 版本1.28.0解决了我的问题,当前版本为1.29.0 https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin (2认同)

Ang*_*i H 247

它发生在我将Android Studio更新到3.3.0之后.build.gradle是原因.我已向Firebase小组发送了有关此问题的错误报告.

你有3个选择:

  • 等到下一版Fabric插件发布.在这里查看最新版本.

  • 降级到Android Studio 3.2.1.

  • 注释掉apply plugin: 'io.fabric'插件.

io.fabric您的应用程序模块中:

classpath 'io.fabric.tools:gradle:1.28.1'
Run Code Online (Sandbox Code Playgroud)

但是,即使出现此错误,您仍可以构建和运行项目.只是忽略它.

  • 这是原因,而不是可行的解决方案 (16认同)
  • 我必须使用`io.fabric`插件然后如何在不改变这个的情况下删除此警告? (8认同)
  • 为什么要降级?没意思!这只是一个警告,它还没有被删除,它可以建立你的项目(整个2019年......).我相信他们会在今年解决这个问题 (4认同)
  • 您是否可以链接到Bug报告或使用Firebase打开的问题?我很乐意投票。 (2认同)

Ame*_*bak 60

在应用程序build.gradle中,降级到这个稳定版本的gradle:

classpath 'com.android.tools.build:gradle:3.2.1'
Run Code Online (Sandbox Code Playgroud)

它发生在我将Android Studio更新为3.3,临时解决方案之后,直到他们修复它!

编辑:你不需要降级你的android工作室!

  • 由于这个建议,它没有降级任何东西 (6认同)
  • 你不需要降级你的android studio @RubénViguera (3认同)
  • 然后你还必须降级到Android Studio 3.2.1.不管怎么说,还是要谢谢你 (2认同)

113*_*408 16

如果在app gradle文件上注释掉classpath 'io.fabric.tools:gradle:1.28.0'插件Crashlytics暂时为你工作了

//apply plugin: 'io.fabric'
Run Code Online (Sandbox Code Playgroud)

然后,在Project gradle文件上升级fabric gradle依赖项将永久解决问题:

classpath 'io.fabric.tools:gradle:1.27.0'
Run Code Online (Sandbox Code Playgroud)

注意:这不会删除警告但让你使用Crashlytics和AS3.3 +


Jud*_*des 13

不确定实际问题是什么,但是从项目中解决了与崩解相关的依赖关系解决了问题.


Ryd*_*yde 11

它被确认为Crashlytics的错误,他们正在努力.

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

引自Google受让人:

je ... @ google.com#23 Jan 23,20199 01:40 AM大家好
,

感谢您的耐心等待.

看起来所有情况下的错误都来自崩溃,我已经向他们提交了一个错误.

我会告诉你最新的状态.

对我来说,我的调试应用程序在我的设备上工作正常,只需运行并忽略警告而不评论Crashlytics或Fabric.我没有尝试过制作.

更新:

Google Issue Tracker已将此问题标记为"无法修复(不可行)",因为所有问题都来自Crashlytics,并且让Crashlytics团队完成修复(尽管他们是相同的Google员工......).

他们建议按照此链接进行Crashlytics更新:

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

注意:我仍在使用Android Studio 3.3和io.fabric.tools:gradle:1.26.0而不评论任何Craslytics,它在我的调试应用程序上工作正常.


Gas*_*lén 8

最新消息来自01/24/2019

在此输入图像描述

有关信息,请访问https://issuetracker.google.com/issues/116408637

我们需要等待直到Crashlytics想出一个解决方案,这里是GitHub问题打开了

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

我现在使用的唯一方法是不评论io.fabric插件是降级我的gradle并升级我的Fabric类路径(这适用于我的生产应用)

 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
    }
Run Code Online (Sandbox Code Playgroud)


Tri*_*ity 5

正如所说,问题出在 Fabric/Crashlytics 上。

apply plugin: 'io.fabric'
Run Code Online (Sandbox Code Playgroud)

这是 Crashlytics/Firebase 方面的错误,请检查以下链接并查看错误状态: https: //github.com/firebase/firebase-android-sdk/issues/198