Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remedy error caused by guava: Program type already present: com.google.common.util.concurrent.internal.InternalFutures

An AAR library already uses com.google.guava.

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

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

like image 200
Hong Avatar asked Dec 08 '22 13:12

Hong


1 Answers

I had to update to version 27.0.1, at the time of writing they still haven't updated the README with this new version.

implementation 'com.google.guava:guava:27.0.1-android'
like image 115
Moses Avatar answered Jun 07 '23 03:06

Moses