处理guava-21.0不兼容Android错误:DexArchiveBuilderException: Failed to process guava-21.0.jar
在Android项目里使用guava-21.0报错:
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\cc\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Error:com.android.tools.r8.ApiLevelException: Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values()
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
原因是guava 21使用的是Java 8,与Android不兼容。
可以把guava 21改为与Android兼容的版本23.3-android
dependencies {
compile 'com.google.guava:guava:23.3-android'
}