我正在运行仪器测试并收到此编译错误:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithR8ForDebugAndroidTest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
...
Caused by: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:108)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
...
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.z.a(:55)
at com.android.tools.r8.R8.runForTesting(:3)
at com.android.tools.r8.R8.run(:3)
at com.android.builder.dexing.R8Tool.runR8(r8Tool.kt:195)
Caused by: com.android.tools.r8.utils.AbortException: Error: offset: 0, line: 16559, column: 1, 'void zza(com.google.android.gms.common.internal.BaseGmsClient,int,android.os.IInterface)' already has a mapping
at com.android.tools.r8.utils.Reporter.a(:21)
at com.android.tools.r8.naming.SeedMapper$a.build(:1)
...
如果我查看,app/build/outputs/mappings/debug/mapping.txt
我会看到该方法列出了两次。
com.google.android.gms.common.internal.BaseGmsClient -> com.google.android.gms.common.internal.BaseGmsClient:
...
344:344:void zza(com.google.android.gms.common.internal.BaseGmsClient,int,android.os.IInterface) -> zza
...
350:350:void zza(com.google.android.gms.common.internal.BaseGmsClient,int,android.os.IInterface) -> zza
- 奇怪的是没有发生在基本的应用程序编译上。不知道为什么 R8 用测试代码做任何事情。
- 这是 R8 问题还是 Play Services 问题?
- 我该如何解决这个问题。gradle clean + invalidate/restart 没有做任何事情,也没有手动删除和重新生成 mappings.txt 文件。