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

时间:2018-09-25 14:28:16

标签: android android-gradle android-workmanager android-guava

由于以下错误,我当前的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

我正在使用Android Studio版本

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

以下链接没有帮助

Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

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

将我的tarke SDK版本et.c从27增加到28

   compileSdkVersion = 28
   targetSdkVersion = 28
   minSdkVersion = 21
   buildToolsVersion = "28.0.2"
   supportLibVersion = "28.0.0"

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

并切换到gradle 3.2.0

 classpath 'com.android.tools.build:gradle:3.2.0'

如何修复我的gradle版本?

更新

正在运行./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 (*)

因此我添加了

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

建立我的gradle

这引起了

More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'

因此我添加了

packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }

现在我的构建完成了

真的很难增加Android版本吗?

0 个答案:

没有答案