如何解决已存在的程序类型:com.google.common.util.concurrent.ListenableFuture?

Hec*_*tor 8 android android-gradle-plugin android-guava android-workmanager

由于以下错误,我现在的Android项目现在无法构建

AGPBI: {"kind":"error","text":"Program type already present: com.google.common.util.concurrent.ListenableFuture","sources":[{}],"tool":"D8"}
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/....
Program type already present: com.google.common.util.concurrent.ListenableFuture
Run Code Online (Sandbox Code Playgroud)

我正在使用Android工作室版本

Android Studio 3.2
Build #AI-181.5540.7.32.5014246, built on September 17, 2018
JRE: 1.8.0_152-release-1136-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
Run Code Online (Sandbox Code Playgroud)

以下链接不太有帮助

Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Run Code Online (Sandbox Code Playgroud)

我为触发此错误所做的更改如下: -

将我的tarke sdk version et.c从27增加到28

   compileSdkVersion = 28
   targetSdkVersion = 28
   minSdkVersion = 21
   buildToolsVersion = "28.0.2"
   supportLibVersion = "28.0.0"
Run Code Online (Sandbox Code Playgroud)

将我的kotlin版本增加到 ext.kotlin_version = '1.2.61'

并切换到gradle 3.2.0

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

如何修复我的gradle构建?

UPDATE

跑了 ./gradlew app:dependencies

我发现了这个

+--- android.arch.work:work-runtime:1.0.0-alpha09
|    +--- android.arch.lifecycle:extensions:1.1.0 -> 1.1.1 (*)
|    +--- androidx.concurrent:futures:1.0.0-alpha01
|    |    +--- com.google.guava:listenablefuture:1.0
|    |    \--- androidx.annotation:annotation:1.0.0-rc01
|    \--- android.arch.persistence.room:runtime:1.1.1-rc1
|         +--- android.arch.persistence.room:common:1.1.1-rc1
|         |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|         +--- android.arch.persistence:db-framework:1.1.1-rc1
|         |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|         |    \--- android.arch.persistence:db:1.1.1-rc1
|         |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|         +--- android.arch.persistence:db:1.1.1-rc1 (*)
|         +--- android.arch.core:runtime:1.1.1 (*)
|         \--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
Run Code Online (Sandbox Code Playgroud)

因此我补充道

api ("android.arch.work:work-runtime:$archWorkerRuntimeVersion") {
        exclude group: 'com.google.guava', module: 'listenablefuture'
    }
Run Code Online (Sandbox Code Playgroud)

我的gradle构建

这造成了

More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'
Run Code Online (Sandbox Code Playgroud)

所以我补充道

packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }
Run Code Online (Sandbox Code Playgroud)

现在我的构建完成了

是否真的需要增加Android版本?