提问人:Jude Fernandes 提问时间:9/20/2018 最后编辑:M.RicciutiJude Fernandes 更新时间:10/15/2021 访问量:74024
API 'variant.getExternalNativeBuildTasks()' 已过时,已替换为 'variant.getExternalNativeBuildProviders()
API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()
问:
将 Android Studio 3.3 Canary 11 与 gradle 插件版本一起使用。尝试同步 gradle 时会抛出以下错误3.3.0-alpha11
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"
}
}
我到底需要在这里改变什么?
项目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'
}
应用 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'
我在 app/build.gradle 文件中跳过了一些常量和其他敏感信息。
答:
问题跟踪器可能指的是“惰性任务配置”——
这至少是任务配置回避所建议的。
但是,当(内部)不会访问该方法时,可能会阻止对这种过时方法的访问,或者当检查可以阻止访问时;或通过其名称访问变体时;或者以某种方式禁用变体的外部本机构建任务。另请参阅单变量项目同步选项,该选项似乎是相关的。BaseVariantImpl
variant.outputs.all
或等待构建工具或...这甚至不是一个,因此投入大量时间可能毫无意义 - 除非用它来提交另一个错误报告。3.3.0-alpha12
3.3.0-beta1
release candidate
评论
android.debug.obsoleteApi=true
Provider
3.3.0
不确定实际问题是什么,但从项目中注释掉与崩溃相关的依赖项解决了问题。
编辑
此问题已在 Fabric 1.28.0 中修复。在项目级别中,添加以下行:build.gradle
classpath 'io.fabric.tools:gradle:1.28.1'
上一个回答
它发生在我将 Android Studio 更新到 3.3.0 之后。 是原因。我已就此问题向 Firebase 团队发送了错误报告。apply plugin: 'io.fabric'
您有 3 个选择:
等到下一个版本的 Fabric 插件发布。在此处查看最新版本。
降级到 Android Studio 3.2.1。
注释掉插件。
io.fabric
在应用的模块中:build.gradle
apply plugin: 'com.android.application'
// apply plugin: 'io.fabric' <== this plugin causes the error
但是,即使出现此错误,您仍然可以生成和运行项目。忽略它。
评论
io.fabric
在应用程序中,降级到这个稳定版本的 gradle:build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
它发生在我将 Android Studio 更新到 3.3 之后,这是一个临时解决方案,直到他们修复它。
编辑:您无需降级 Android Studio
评论
当我打开项目时,我按下了右下角出现的按钮。执行了迁移,并在不注释掉依赖项的情况下解决了问题。Run migrations
Android Studio
Crashlytics
将模块文件中的源代码兼容性更改为 Java 8 可修复此问题build.gradle
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
请务必在添加这些行后重新生成项目
评论
build.gradle
此问题已在最新版本的 Fabric gradle 插件 1.28.0 中修复,该插件于今天上线。 在顶级 build.gradle 中包含以下内容:
buildscript {
// ... repositories, etc. ...
dependencies {
// ...other dependencies ...
**classpath 'io.fabric.tools:gradle:1.28.0'**
}
这将修复错误: 在任务栏上,单击“工具”->“Kotlin”->在 Project 中配置 Kotlin
构建日志打印如何调试它,特别是你需要运行构建,这将打印对已弃用 API 的调用的堆栈跟踪,您将能够确定哪个插件/代码调用它。-Pandroid.debug.obsoleteApi=true
如果它最终成为你的代码 — 使用新的提供程序 API(阅读延迟任务配置文档)
如果它来自其他插件 - 向他们报告堆栈跟踪和警告消息,并可能提交补丁。在这种情况下,它与问题有关。io.fabric
就我而言,我需要使用 io.fabric
插件,解决方案是更新到最新的 fabric tools gradle 版本:
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'io.fabric.tools:gradle:1.27.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+ 一起使用
评论
crashlytics
对于那些需要保持 Fabric 插件应用的人来说,临时解决方案是在项目级别回到以前版本的 gradle。
将类路径版本更改为 。com.android.tools.build:gradle:3.2.1
它被确认为 Crashlytics 的错误,他们正在研究它。
https://issuetracker.google.com/issues/116408637
引自 Google 受让人:
[email protected] #23 1月 23, 2019 01:40AM
大家好,感谢您的耐心等待。
看起来所有情况下的错误都来自crashlytics,我已经 向他们提交了一个错误。
我会及时向您通报最新状态。
对我来说,我的调试应用程序只需运行并忽略警告而不评论 Crashlytics 或 Fabric,就可以在我的设备上正常工作。我没有尝试生产。
更新:
Google Issue Tracker 已将此问题标记为“无法修复(不可行)”,因为所有问题都来自 Crashlytics,并让 Crashlytics 团队完成修复(尽管它们是同一个 Googler......
他们建议点击此链接以获取 Crashlytics 更新:
https://github.com/firebase/firebase-android-sdk/issues/198
注意:我仍在使用 Android Studio 3.3 和 io.fabric.tools:gradle:1.26.0,没有评论任何 Craslytics,它在我的调试应用程序上运行良好。
更新:
我现在可以确认它在我的生产/发布版本应用程序上运行良好。我怎么知道它有效?因为它发回了崩溃报告-_-'
无论如何,只需忽略警告,他们最终应该修复它。
哇,刚刚读到它已经用 Fabric 1.28.0 修复:)
最新消息 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
}
评论
-dontwarn com.crashlytics.android.Crashlytics
proguard-rules.pro
如前所述,问题出在 Fabric/Crashlytics 上。
apply plugin: 'io.fabric'
这是 Crashlytics/Firebase 方面的一个错误,请查看以下链接并查看错误状态: https://github.com/firebase/firebase-android-sdk/issues/198
首先,这不是一个错误
这是警告
和 当 gradle 更新到 3.3.0 时,它会显示 经常发生,因为 io.fabric 所以等到更新结构 仍显示警告的当前版本为“io.fabric.tools:gradle:1.27.1”
这是由于您的 Android Studio 从 Android Studio 3.2.0 更新到 Android Studio 3.3.0 造成的。更新 IO 的 Gradle 依赖项(项目)。织物。喜欢:
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'
}
}
该问题已在其最新版本中修复'io.fabric.tools:gradle:1.30.0'
请使用 1.30.0 更新您的两个 gradle 结构工具
buildscript {
// ... repositories, etc. ...
dependencies {
// ...other dependencies ...
classpath 'io.fabric.tools:gradle:1.30.0'
}
}
欲了解更多详情,请 https://github.com/firebase/firebase-android-sdk/issues/198#issuecomment-473435453
评论
classpath 'io.fabric.tools:gradle:1.31.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
对我来说,我遵循了以下步骤: 1. 升级项目级别的 Gradle 依赖项 build.gradle。
classpath 'io.fabric.tools:gradle:1.28.0'
在应用级别 build.gradle 中将此插件依赖项添加到应用插件:“com.android.application”下方。
apply plugin: 'io.fabric'
将项目与 gradle 文件同步。
修复是将根构建 gradle 文件更新为最新版本。这个答案现在是正确的。在未来,Gradle 和 Android SDK 将再次实施新的更改。有时答案会在适当的时候有所不同。
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'
}
评论