我正在尝试迁移到新的Places SDK for Android Client。
我进行了必要的代码更改,但是在:app:transformClassesWithDexBuilderForDebug任务上打包应用程序失败(请参见下面的堆栈跟踪)。问题似乎出在com.google.android.libraries.places:places:1.0.0的一部分com.google.guava:guava-jdk5:17.0依赖项中。
部分依赖树是:
com.google.android.libraries.places:places:1.0.0
| ...
| \--- com.google.guava:guava:23.5-android
...
+--- com.google.api-client:google-api-client-android:1.23.0
| +--- com.google.api-client:google-api-client:1.23.0
| | ...
| | \--- com.google.guava:guava-jdk5:17.0
因此,新的Places SDK客户端库两次包含Guava,并且还包含非Android版本,这会导致编译错误。我认识到该描述看起来像是一个错误描述,但是指向相关错误跟踪器的链接也不起作用:(
Caused by: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process ~/.gradle/caches/modules-2/files-2.1/com.google.guava/guava-jdk5/17.0/463f8378feba44df7ba7cd9272d01837dad62b36/guava-jdk5-17.0.jar
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
at com.android.ide.common.internal.WaitableExecutor.waitForTasksWithQuickFail(WaitableExecutor.java:146)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:405)
... 53 more
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process ~/.gradle/caches/modules-2/files-2.1/com.google.guava/guava-jdk5/17.0/463f8378feba44df7ba7cd9272d01837dad62b36/guava-jdk5-17.0.jar
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:900)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.lambda$convertToDexArchive$6(DexArchiveBuilderTransform.java:825)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
at com.android.builder.dexing.D8DexArchiveBuilder.getExceptionToRethrow(D8DexArchiveBuilder.java:124)
at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:101)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:895)
... 6 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:65)
at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:43)
at com.android.tools.r8.D8.run(D8.java:90)
at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:99)
... 7 more
Caused by: com.android.tools.r8.utils.AbortException: Error: Type com.google.common.util.concurrent.Futures$FutureCombiner is referenced as an interface from `com.google.common.util.concurrent.Futures$7`.
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:116)
at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:74)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:59)
... 10 more
最佳答案
迁移到新的Places SDK时,我遇到了完全相同的问题,并且通过排除com.google.guava:guava-jdk5
依赖性解决了该问题
implementation ('com.google.android.libraries.places:places:1.0.0') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
如果您还有另一个依赖于 Guava 的依赖项,则可能需要排除整个组,而不仅仅是
guava-jdk5
模块。implementation ('com.google.android.libraries.places:places:1.0.0') {
exclude group: 'com.google.guava'
}
关于android - 在transformClassesWithDexBuilder上为Android客户端库编译新的Places SDK失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54553477/