如何解决由番石榴引起的错误:程序类型已存在: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

查看:193
本文介绍了如何解决由番石榴引起的错误:程序类型已存在: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):

  1. 排除"listenablefuture"模块(组"com.google.guava")并重新构建项目.
  2. 我不知道AAR的详细信息,但可能是27.0-android无法与AAR一起使用,因此您应该尝试使用26.0-android.
  1. Exclude "listenablefuture" module (group "com.google.guava") and build your project again.
  2. I don't know the AAR specifics, but it could be that 27.0-android doesn't work with AAR, so you should try 26.0-android instead.

这篇关于如何解决由番石榴引起的错误:程序类型已存在:com.google.common.util.concurrent.internal.InternalFutures的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆