android - API'variable.getExternalNativeBuildTasks()'已過時,已替換為'variant.getExternalNativeBuildProviders()




firebase android-studio (14)

不確定實際問題是什麼,但是從項目中解決了與崩解相關的依賴關係解決了問題。

使用Android Studio 3.3 Canary 11和gradle插件版本 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

單擊錯誤會將我引導至gradle文件中的此行

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

我到底需要改變什麼?

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:[email protected]'
    implementation 'com.daimajia.androidanimations:library:[email protected]'

    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:[email protected]') {
        transitive = true
    }
    api('com.crashlytics.sdk.android:answers:[email protected]') {
        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'

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


問題跟踪器可能會引用“懶惰任務配置” -

這至少是 避免任務配置的 建議。

但是當 variant.outputs.all 不能訪問該方法(內部)時,或者當檢查可以阻止訪問時,可能會阻止訪問這個過時的 BaseVariantImpl 方法; 或者當用它的名字訪問變體時; 或以某種方式禁用變體的外部本機構建任務。 還可以看到 單變量項目同步 選項,這看起來很相關。

或等待 build-tools 3.3.0-alpha123.3.0-beta1 ......這甚至都不是 release candidate ,因此投入大量時間可能毫無意義 - 除非使用它來提交另一個錯誤報告。

新的快速反饋 按鈕仍然看起來最有前途。


在我的情況下,我需要使用 io.fabric 插件,解決方案是,更新到最新的Fabric工具gradle版本:

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


將模塊 build.gradle 文件中的源兼容性更改為Java 8可以解決此問題

compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}

確保在添加這些行後重建項目


對我來說,我遵循以下步驟:1。升級項目級build.gradle的Gradle依賴項。

        classpath 'io.fabric.tools:gradle:1.28.0'
  1. 在應用程序級別build.gradle中添加此插件依賴項以下 應用插件:'com.android.application'

        apply plugin: 'io.fabric'
  2. 使用gradle文件同步項目。


最新消息來自01/24/2019

有關信息,請訪問 issuetracker.google.com/issues/116408637

我們需要等待直到Crashlytics想出一個解決方案,這裡是GitHub問題打開了

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

我現在使用的唯一方法是不評論 io.fabric 插件是降級我的gradle併升級我的結構類路徑(這適用於我的生產應用程序)

 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
    }

構建日誌打印如何調試它,特別是你需要使用 -Pandroid.debug.obsoleteApi=true 運行構建,這將打印堆棧跟踪調用已棄用的API,你將能夠確定哪個插件/代碼調用它。

如果它最終成為您的代碼 - 使用新的Provider API( 閱讀Lazy Task Configuration doc

如果它來自其他插件 - 使用堆棧跟踪和警告消息向他們報告並可能提交補丁。 在這種情況下,它與 io.fabric 問題有關。



這將修復錯誤:在任務欄上單擊工具 - > Kotlin->在項目中配置Kotlin


這是因為您的Android Studio從Android Studio 3.2.0更新到Android Studio 3.3.0。 更新IO.Fabric的Gradle依賴項(Project)。 喜歡:

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

並將您的Kotlin版本更新為

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

這將解決這個問題。 謝謝


這是最新 gradle (在我的情況下為 3.3.2 )版本和 Fabric.io 插件的問題。 它現在由新版本解決用戶應該在他們的頂級 build.gradle

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

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

更新 截至今天,您可以使用 classpath 'io.fabric.tools:gradle:1.28.0' 來解決此問題!

如果在應用程序gradle文件中評論出 Crashlytics 的插件 io.fabric 暫時為你工作

//apply plugin: 'io.fabric'

然後,在Project gradle文件上升級fabric gradle依賴項將永久解決問題:

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

注意:這不會刪除警告但讓你使用Crashlytics和AS3.3 +


編輯

docs.fabric.io/android/changelog.html#march-15-2019 已修復此問題。 在項目級別的 build.gradle 中,添加以下行:

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

上一個答案

它發生在我將Android Studio更新到3.3.0之後。 apply plugin: 'io.fabric' 是原因。 我已向Firebase小組發送了有關此問題的錯誤報告。

你有3個選擇:

在app的模塊的 build.gradle 中:

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

但是,即使出現此錯誤,您仍可以構建和運行項目。 只是忽略它。





fabric.io