更新到WorkManager 1.0.0-alpha09后编译错误 [英] Compile errors after updating to WorkManager 1.0.0-alpha09
问题描述
我正在尝试从体系结构组件中使用WorkManager.我已经将compileSdkVersion和targetSdkVersion从27升级到28.gradle同步已成功完成.但是构建时错误不断弹出. android.support库使用的版本为28.0.0-rc02,因为存在"android.support:design".
I'm trying to use WorkManager from architecture components. I've upgraded the compileSdkVersion and targetSdkVersion from 27 to 28. gradle sync is successfully done. But build-time error keeps popping up. android.support libraries are using version 28.0.0-rc02 because of the 'android.support:design'.
我试图添加PackagingOptions以排除"proguard/androidx-annotations.pro".但这没有帮助.但这一次,我收到了另一条错误消息:
I've tried to add packagingOptions in order to exclude 'proguard/androidx-annotations.pro'. But it didn't help. But this time I got a different error message:
Program type already present: com.google.common.util.concurrent.ListenableFuture
我不知道出了什么问题.
I could not figure out what's going wrong.
build.gradle:
build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.apps.test"
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "bool", "enableFirebase", "true"
}
debug {
minifyEnabled false
resValue "bool", "enableFirebase", "false"
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
// implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:design:28.0.0-rc02'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
implementation 'com.android.support:support-v4:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
//Arch
implementation 'android.arch.core:runtime:1.1.1'
implementation 'android.arch.core:common:1.1.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha09"
// implementation "android.arch.work:work-firebase:1.0.0-alpha09"
}
apply plugin: 'com.google.gms.google-services'
我已经在gradle 像这里一样
I've implemented the packagingOptions in gradle like in here
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
但是这次我又遇到了5个错误:
But this time I got 5 additional errors:
1:
Program type already present: com.google.common.util.concurrent.ListenableFuture
Message{kind=ERROR, text=Program type already present: com.google.common.util.concurrent.ListenableFuture, sources=[Unknown source file], tool name=Optional.of(D8)}
2:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: ...
3:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: ...
4:
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
5:
Caused by: com.android.tools.r8.utils.AbortException
推荐答案
按照 WorkManager 1.0.0-alpha09发行说明:
已知问题
如果遇到以下问题:使用操作系统独立路径'META-INF/proguard/androidx-annotations.pro'找到了多个文件",请将以下内容作为临时解决方法放在gradle文件中,我们在alpha10中修复了该问题:
If you run into the following issue: "More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'", please put the following in your gradle file as a temporary workaround while we fix the issue in alpha10:
android {
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
您的其他错误是由此问题引起的:
Your additional errors are caused by this issue:
这是有意完成的: https://groups.google. com/forum/#!topic/guava-announce/Km82fZG68Sw
新版本的番石榴即将面世,它将自动解决该问题.
New release of guava will be ready soon, that will resolve that issue automatically.
目前,您可以在gradle文件中排除"com.google.guava:listenablefuture"
:
For now you can exclude "com.google.guava:listenablefuture"
in your gradle file:
implementation("android.arch.work:work-runtime:1.0.0-alpha09") {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
这篇关于更新到WorkManager 1.0.0-alpha09后编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!