使用带有 gradle 插件版本 3.3.0-alpha11
的 Android Studio 3.3 Canary 11。尝试同步 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"
}
}
我到底需要在这里改变什么?
项目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'
}
应用程序构建.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 文件中跳过了一些常量和其他敏感信息。
该问题已在其最新版本 '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'
}
}
更多详情https://github.com/firebase/firebase-android-sdk/issues/198#issuecomment-473435453
编辑
此问题已在 Fabric 1.28.0 中修复。在您的项目级别的 build.gradle
中,添加以下行:
classpath 'io.fabric.tools:gradle:1.28.1'
上一个答案
它发生在我将 Android Studio 更新到 3.3.0 之后。 apply plugin: 'io.fabric'
是原因。我已向 Firebase 团队发送了一份关于此问题的错误报告。
您有 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
插件,那么如何在不更改此警告的情况下删除此警告?
在应用程序 build.gradle
中,降级到这个稳定版本的 gradle:
classpath 'com.android.tools.build:gradle:3.2.1'
它发生在我将 Android Studio 更新到 3.3 之后,这是一个临时解决方案,直到他们修复它。
编辑:你不需要降级你的 Android Studio
更新 从今天开始,您可以使用 classpath 'io.fabric.tools:gradle:1.28.0'
来解决此问题!
如果在应用程序 gradle 文件中注释掉 Crashlytics
的插件 io.fabric
暂时对您有用
//apply plugin: 'io.fabric'
然后升级您对项目 gradle 文件的结构 gradle 依赖项将永久解决该问题:
classpath 'io.fabric.tools:gradle:1.27.0'
注意:这不会删除警告,但可以让您将 Crashlytics 与 AS3.3+ 一起使用
crashlytics
的情况下编译项目。因此,要保留 Crashlytics 并继续推动 prod,您可以使用上述更新,即使它仍会触发“警告”。
不确定实际问题是什么,但从项目解决的问题中注释掉与 crashlytics 相关的依赖项。
它已被确认为 Crashlytics 的错误,他们正在努力解决。
https://issuetracker.google.com/issues/116408637
引自谷歌受让人:
je...@google.com #23 Jan 23, 2019 01:40AM 大家好,感谢您的耐心等待。看起来所有情况下的错误都来自崩溃分析,我已经向他们提交了错误。我会及时通知您最新状态。
对我来说,我的调试应用程序在我的设备上运行良好,只需运行并忽略警告而不评论 Crashlytics 或 Fabric。我还没有尝试生产。
更新:
Google 问题跟踪器已将此问题标记为无法修复(不可行),因为所有问题都来自 Crashlytics,并让 Crashlytics 团队完成修复(尽管他们是同一个 Google 员工......)。
他们建议点击此链接获取 Crashlytics 更新:
https://github.com/firebase/firebase-android-sdk/issues/198
注意:我仍在使用带有 io.fabric.tools:gradle:1.26.0 的 Android Studio 3.3,而没有评论任何 Craslytics,它在我的调试应用程序上运行良好。
更新:
我现在可以确认它在我的生产/发布版本应用程序上运行良好。我怎么知道它有效?因为它给我发回了崩溃报告-_-'
无论如何,只需忽略警告,他们最终应该修复它。
哇,刚刚读到它已经用织物 1.28.0 修复了 :)
2019 年 1 月 24 日最新消息
https://i.stack.imgur.com/fqXMM.png
此处的信息https://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
}
proguard-rules.pro
中添加 -dontwarn com.crashlytics.android.Crashlytics
怎么样
如前所述,问题出在 Fabric/Crashlytics 上。
apply plugin: 'io.fabric'
这是 Crashlytics/Firebase 方面的错误,请检查以下链接并查看错误状态:https://github.com/firebase/firebase-android-sdk/issues/198
问题跟踪器可能指的是“惰性任务配置” -
这至少是 task configuration avoidance 所暗示的。
但是当 variant.outputs.all
不会(内部)访问该方法时 - 或者当检查可以阻止访问时,可能会阻止访问 BaseVariantImpl
的这个过时方法;或通过名称访问变体时;或以某种方式禁用变体的外部本机构建任务。另请参阅 single-variant project sync 选项,这似乎是相关的。
或等待 build-tools 3.3.0-alpha12
或 3.3.0-beta1
...这甚至不是 release candidate
,因此投入大量时间可能毫无意义 - 除非使用它来提交另一个错误报告。
https://i.stack.imgur.com/4tEX9.png
android.debug.obsoleteApi=true
以查看它的来源。有一些方法被重命名,在它们的名字后面附加了 Provider
。
3.3.0
版本破坏了一些东西,因为变体 API 已经改变。可以链接一个最近的讨论:stackoverflow.com/questions/54206898/…(在那里添加了一个摘要作为答案)。
对我来说,我遵循了以下步骤: 1. 升级项目级别 build.gradle 的 Gradle 依赖项。
classpath 'io.fabric.tools:gradle:1.28.0'
在应用级别 build.gradle 中添加此插件依赖项 apply plugin: 'com.android.application'。 apply plugin: 'io.fabric' 将项目与 gradle 文件同步。
这是因为您的 Android Studio 从 Android Studio 3.2.0 更新到了 Android Studio 3.3.0。更新 IO.Fabric 的 Gradle 依赖项(项目)。喜欢:
classpath 'io.fabric.tools:gradle:1.27.1'
并将您的 Kotlin 版本更新为
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
这将解决这个问题。谢谢
构建日志会打印如何调试它,特别是您需要使用 -Pandroid.debug.obsoleteApi=true
运行构建,这将打印对已弃用 API 的调用的堆栈跟踪,您将能够确定哪个插件/代码调用它。
如果它最终成为您的代码 — 使用新的 Provider API (read Lazy Task Configuration doc)
如果它来自其他插件 - 向他们报告堆栈跟踪和警告消息,并可能提交补丁。在这种情况下,它与 io.fabric
问题有关。
这已在最新版本的 Fabric gradle 插件 1.28.0 中得到修复,该插件已于今天上线。在你的顶级 build.gradle 中有这个:
buildscript {
// ... repositories, etc. ...
dependencies {
// ...other dependencies ...
**classpath 'io.fabric.tools:gradle:1.28.0'**
}
当我打开项目时,我按下了出现在 Android Studio
右下角的 Run migrations
按钮。执行了迁移并在没有注释掉 Crashlytics
依赖项的情况下解决了问题。
https://i.stack.imgur.com/WER35.png
将模块 build.gradle
文件中的源代码兼容性更改为 Java 8 解决了该问题
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
添加这些行后,请务必重建项目
build.gradle
或模块级别 (/app) 中?
这将修复错误:在任务栏上单击 Tools->Kotlin->Configure Kotlin in Project
就我而言,我需要使用 io.fabric
插件,解决方案是更新到最新的 Fabric 工具 gradle 版本:
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'io.fabric.tools:gradle:1.27.0'
对于那些需要保持 Fabric 插件应用的人,临时的解决方案是在项目级别回到之前版本的 gradle。
将类路径版本更改为 com.android.tools.build:gradle:3.2.1
。
这是最新的 gradle
(在我的情况下为 3.3.2
)版本和 Fabric.io
插件的问题。现在新版本解决了这个问题用户应该在他们的顶级 build.gradle
中有这个:
buildscript {
// ... repositories, etc. ...
dependencies {
// ...other dependencies ...
classpath 'io.fabric.tools:gradle:1.28.0'
}
}
修复是将根构建 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'
}
首先,这不是错误
这是警告
并且它在更新 gradle 到 3.3.0 时出现 经常发生因为 io.fabric 所以等到更新结构当前版本仍然显示警告是'io.fabric.tools:gradle:1.27.1'
classpath 'io.fabric.tools:gradle:1.31.0'
和implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
相关的警告。对于所有情况,它要么再次损坏,要么未修复。