如何解决由番石榴引起的错误:程序类型已存在:com.google.common.util.concurrent.internal.InternalFutures [英] How to remedy error caused by guava: Program type already present: com.google.common.util.concurrent.internal.InternalFutures
问题描述
一个AAR库已经使用com.google.guava.
An AAR library already uses com.google.guava.
如果某个应用在其build.gradle中包含以下内容:
If an app includes the following in its build.gradle:
api 'com.google.guava:guava:27.0-android'
构建应用程序会产生以下错误:
Building the app generates the following error:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: ...
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.google.common.util.concurrent.internal.InternalFutures
如果我不包含"api'com.google.guava:guava:27.0-android'",则可以构建该应用程序,但在使用时会出现java.lang.NoClassDefFoundError的运行时错误.番石榴方法:Iterables.find
If I do not include "api 'com.google.guava:guava:27.0-android'", the app can be built, but it has runtime error of java.lang.NoClassDefFoundError when it reaches the point of using the Guava method: Iterables.find
推荐答案
由于Guava 27.0 和ListenableFuture
位于单独的工件中,请参见公告.您可以尝试两种方法(一次尝试一种):
Since Guava 27.0, ListenableFuture
is located in separate artifact, see the announcement. You can try two things (one at a time):
- 排除
"listenablefuture"
模块(组"com.google.guava"
)并重新构建项目. - 我不知道AAR的详细信息,但可能是
27.0-android
无法与AAR一起使用,因此您应该尝试使用26.0-android
.
- Exclude
"listenablefuture"
module (group"com.google.guava"
) and build your project again. - I don't know the AAR specifics, but it could be that
27.0-android
doesn't work with AAR, so you should try26.0-android
instead.
这篇关于如何解决由番石榴引起的错误:程序类型已存在:com.google.common.util.concurrent.internal.InternalFutures的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!