Failed to find byte code for java/util/function/BiConsumer - android

This problem happened on API 23.I think this is lambda conversion problem.
I wrote listener functions like this:
fun read(child: String, onSuccess: (datas: List<RestaurantModel>) -> Unit, onFailure: (errMsg: String) -> Unit) {}
It's working great on API 27.I don't wanna write interface for this pattern.This lambdas more clean for me.Does anybody know the solution?
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Failed to find byte code for java/util/function/BiConsumer
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more
Caused by: com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Failed to find byte code for java/util/function/BiConsumer
at com.android.build.gradle.internal.transforms.InstantRunTransform.doTransform(InstantRunTransform.java:312)
at com.android.build.gradle.internal.transforms.InstantRunTransform.transform(InstantRunTransform.java:178)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 48 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Failed to find byte code for java/util/function/BiConsumer
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.InstantRunTransform.doTransform(InstantRunTransform.java:307)
... 52 more
Caused by: java.lang.RuntimeException: java.io.IOException: Failed to find byte code for java/util/function/BiConsumer
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)
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: java.io.IOException: Failed to find byte code for java/util/function/BiConsumer
at com.android.build.gradle.internal.incremental.AsmUtils.lambda$static$0(AsmUtils.java:89)
at com.android.build.gradle.internal.incremental.AsmUtils.loadClass(AsmUtils.java:307)
at com.android.build.gradle.internal.incremental.AsmUtils.readInterfaceHierarchy(AsmUtils.java:216)
at com.android.build.gradle.internal.incremental.AsmUtils.readInterfaces(AsmUtils.java:251)
at com.android.build.gradle.internal.incremental.AsmUtils.loadClass(AsmUtils.java:288)
at com.android.build.gradle.internal.incremental.IncrementalVisitor.instrumentClass(IncrementalVisitor.java:342)
at com.android.build.gradle.internal.transforms.InstantRunTransform.transformToClasses2Format(InstantRunTransform.java:406)
at com.android.build.gradle.internal.transforms.InstantRunTransform.lambda$doTransform$3(InstantRunTransform.java:268)
at com.android.build.gradle.internal.transforms.InstantRunTransform.lambda$null$4(InstantRunTransform.java:297)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)

I found the problem.It's gradle bug.I downgraded gradle version to 3.0.0.It's compiling now.
This bug is fixed in last version.You don't need downgrade.Just update your gradle version to last.

BiConsumer is part of the Java 8 Platform and was introduce to Android in API 24. (reference)
When building your project to Java 8, kotlin lambda's are converted to Java 8 functional interfaces
In your build.gradle app. Try compiling your project with Java 7
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
}
kotlinOptions {
jvmTarget = "1.6"
}

It's bit late, but I found this bug when using Map.forEach standard method, and it accepts BiConsumer (in my case I didn't use it explicitly as I'm also developing in Kotlin, so I just passed lambda with two parameters)
And indeed it works ok with gradle plugin 3.0.0 - so it looks like some regression - for some reason it's missing from newer releases

1) Clean Your Project
2) Restart Your Android Studio with Invalidate cache and restart
3) Rebuild Your Project

Related

Android Studio (3.2.1) Instant Run doesn't work with Jacoco 0.8.2?

I created a simple Empty Activity project (Java) with Android Studio 3.2.1. It compiles fine with Instant Run on.
However, when I add Jacoco 0.8.2 to the class path
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'org.jacoco:org.jacoco.core:0.8.2' //<--Added this
}
When I compile, it get error
:app:transformClassesWithInstantRunForDebug 134 ms
Disable Instant Run would be okay. Is this a bug in Jacoco or Android sdk?
Updated with Error Description
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.lang.IllegalStateException: java.lang.IllegalStateException
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
... 33 more
Caused by: com.android.build.api.transform.TransformException: java.lang.IllegalStateException: java.lang.IllegalStateException
at com.android.build.gradle.internal.transforms.InstantRunTransform.doTransform(InstantRunTransform.java:320)
at com.android.build.gradle.internal.transforms.InstantRunTransform.transform(InstantRunTransform.java:186)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 49 more
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException
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.InstantRunTransform.doTransform(InstantRunTransform.java:315)
... 53 more
Caused by: java.lang.IllegalStateException
at org.objectweb.asm.tree.analysis.BasicInterpreter.<init>(BasicInterpreter.java:66)
at com.android.build.gradle.internal.incremental.ConstructorBuilder$1.<init>(ConstructorBuilder.java:127)
at com.android.build.gradle.internal.incremental.ConstructorBuilder.build(ConstructorBuilder.java:127)
at com.android.build.gradle.internal.incremental.IncrementalSupportVisitor.visitMethod(IncrementalSupportVisitor.java:223)
at org.objectweb.asm.ClassVisitor.visitMethod(ClassVisitor.java:327)
at org.objectweb.asm.commons.SerialVersionUIDAdder.visitMethod(SerialVersionUIDAdder.java:236)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:686)
at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:436)
at com.android.build.gradle.internal.incremental.IncrementalVisitor.instrumentClass(IncrementalVisitor.java:365)
at com.android.build.gradle.internal.transforms.InstantRunTransform.transformToClasses2Format(InstantRunTransform.java:414)
at com.android.build.gradle.internal.transforms.InstantRunTransform.lambda$doTransform$4(InstantRunTransform.java:276)
at com.android.build.gradle.internal.transforms.InstantRunTransform.lambda$null$5(InstantRunTransform.java:305)
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)
Quoting my answer at https://github.com/jacoco/jacoco/issues/779#issuecomment-434281431 :
As you can see - exception originates from
com.android.build.gradle.internal:
Caused by: java.lang.IllegalStateException
at org.objectweb.asm.tree.analysis.BasicInterpreter.<init>(BasicInterpreter.java:66)
at com.android.build.gradle.internal.incremental.ConstructorBuilder$1.<init>(ConstructorBuilder.java:127)
at com.android.build.gradle.internal.incremental.ConstructorBuilder.build(ConstructorBuilder.java:127)
at com.android.build.gradle.internal.incremental.IncrementalSupportVisitor.visitMethod(IncrementalSupportVisitor.java:223)
at org.objectweb.asm.ClassVisitor.visitMethod(ClassVisitor.java:327)
at org.objectweb.asm.commons.SerialVersionUIDAdder.visitMethod(SerialVersionUIDAdder.java:236)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:686)
at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:436)
at com.android.build.gradle.internal.incremental.IncrementalVisitor.instrumentClass(IncrementalVisitor.java:365)
at com.android.build.gradle.internal.transforms.InstantRunTransform.transformToClasses2Format(InstantRunTransform.java:414)
at com.android.build.gradle.internal.transforms.InstantRunTransform.lambda$doTransform$4(InstantRunTransform.java:276)
at com.android.build.gradle.internal.transforms.InstantRunTransform.lambda$null$5(InstantRunTransform.java:305)
Code of
com.android.build.gradle.internal.incremental.ConstructorBuilder.build
that causes exception at
ConstructorBuilder.java:127:
BasicInterpreter interpreter = new BasicInterpreter() {
which is incorrect according to Javadoc of constructor
org.objectweb.asm.tree.analysis.BasicInterpreter that throws
exception at
BasicInterpreter.java:66:
/**
* Constructs a new {#link BasicInterpreter} for the latest ASM API version. <i>Subclasses must
* not use this constructor</i>. Instead, they must use the {#link #BasicInterpreter(int)}
* version.
*/
public BasicInterpreter() {
super(ASM6);
if (getClass() != BasicInterpreter.class) {
throw new IllegalStateException();
}
}
Clearly this should be reported to developers of Android SDK -
https://developer.android.com/studio/report-bugs.html
One might wonder why exception doesn't happen without last line in
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'org.jacoco:org.jacoco.core:0.8.2'
And the reason is similar to
https://github.com/jacoco/jacoco/issues/639#issuecomment-355424756 -
multiple ASM versions in classpath:
JaCoCo 0.8.2 requires ASM 6.2.1 and org.jacoco:org.jacoco.core:0.8.2 correctly declares dependencies on
ASM
exception was added in ASM 6.1
com.android.build.gradle.internal.incremental.ConstructorBuilder most likely was developed / uses older version of ASM
To avoid such classpath issues, developers of Android SDK can
reconsider the way they execute JaCoCo and for example use dedicated
ClassLoader.
As a possible workaround you can try to use JaCoCo 0.8.1 that depends
on ASM 6.0
As a possible workaround you can try to use JaCoCo 0.8.1 that depends on ASM 6.0.

Always rebuild projects after changed androidTest code, when update grade to java8

Before upgrading the version of Java from 1.7 to 1.8, a bunch of test case which is running fine. But, after that, when I change any test case and run the project always failed, must be rebuild all projects.
According to the exception below, I guess that desugaring class occurs errors ,and desugaring is related with Java8.
any one have good idea?
org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':app:app:transformClassesWithDesugarForDevelopmentDebugAndroidTest'. at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at
org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at
org.gradle.api.internal.tasks.execution.SkipCachedTaskExecuter.execute(SkipCachedTaskExecuter.java:108)
at
org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at
org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at
org.gradle.api.internal.tasks.execution.ResolveBuildCacheKeyExecuter.execute(ResolveBuildCacheKeyExecuter.java:61)
at
org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at
org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at
org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at
org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at
org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at
org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at
org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at
org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at
org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.RuntimeException:
com.android.build.api.transform.TransformException:
java.lang.ArrayIndexOutOfBoundsException at
com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at
com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at
com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at sun.reflect.GeneratedMethodAccessor2173.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at
org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at
org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at
org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 34 more Caused by:
com.android.build.api.transform.TransformException:
java.lang.ArrayIndexOutOfBoundsException at
com.android.build.gradle.internal.transforms.DesugarTransform.transform(DesugarTransform.java:292)
at
com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
at
com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
at
com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 49 more Caused by: java.lang.ArrayIndexOutOfBoundsException 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:598)
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.DesugarIncrementalTransformHelper.getInitalGraphData(DesugarIncrementalTransformHelper.java:162)
at
com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.lambda$makeDesugaringGraph$2(DesugarIncrementalTransformHelper.java:134)
at
com.android.builder.desugaring.DesugaringGraphs.forVariant(DesugaringGraphs.java:50)
at
com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.makeDesugaringGraph(DesugarIncrementalTransformHelper.java:132)
at
com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:160)
at
com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.getAdditionalPaths(DesugarIncrementalTransformHelper.java:111)
at
com.android.build.gradle.internal.transforms.DesugarTransform.incrementalAnalysis(DesugarTransform.java:305)
at
com.android.build.gradle.internal.transforms.DesugarTransform.transform(DesugarTransform.java:264)
... 52 more Caused by: java.lang.ArrayIndexOutOfBoundsException
Firstly ,I'm sorry for this question as no description.
Before we upgrading the version of Java from 1.7 to 1.8, writing androidTest code is ok. After that ,when we change any codes and run with androidTest project always failed, must be rebuild all projects.
According to the exception above, guess that desugaring class occurs errors ,and desugaring is related with Java8.

Gradle compile to implmentation

I recently updated my android studio to latest and it install gradle 4.4. After update, my project pop up errors asking to change compile to implementation and I did. But I don't know how to change local android archive resource in library to control special hardware in my app. My case is similar to this stackoverflow link. But I am trying to migrate to newer gradle version. this is how it goes.
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name: 'MyLibrarySdk_1.0.0', ext: 'arr')
}
Following is errors:
> Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
I have tried this code.
implementation(name:'MyLibrarySdk_1.0.0', ext: 'arr')
I got following error.
> org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\2.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\3.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\4.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\5.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\10.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\12.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\13.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\14.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\15.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\16.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\17.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\18.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\19.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\20.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\21.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\22.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\23.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\24.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\25.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\26.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\27.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\28.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\29.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\30.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\31.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\32.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\33.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\34.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\35.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\36.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\37.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\38.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\39.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\40.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\41.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\42.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\43.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\44.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\45.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\46.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\47.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\48.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\49.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\50.jar
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at sun.reflect.GeneratedMethodAccessor303.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\2.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\3.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\4.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\5.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\10.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\12.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\13.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\14.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\15.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\16.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\17.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\18.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\19.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\20.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\21.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\22.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\23.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\24.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\25.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\26.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\27.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\28.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\29.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\30.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\31.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\32.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\33.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\34.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\35.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\36.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\37.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\38.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\39.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\40.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\41.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\42.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\43.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\44.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\45.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\46.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\47.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\48.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\49.jar, C:\Users\phone\Desktop\AndroidProjects\SanbotWebLink\app\build\intermediates\transforms\dexBuilder\debug\50.jar
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:124)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:109)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
at com.android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:123)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 47 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:76)
at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
at com.android.tools.r8.D8.run(D8.java:67)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:107)
... 52 more
Caused by: com.android.tools.r8.utils.AbortException
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:77)
at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:58)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:67)
... 55 more
I notice that after gradle change, it can sync successfully but it failed at compilation. There is one more android issue as follows.
Program type already present: kotlin.AutoCloseableKt
Message{kind=ERROR, text=Program type already present:
kotlin.AutoCloseableKt, sources=[Unknown source file], tool
name=Optional.of(D8)}
How can i change compile to implementation? Please help me out.
I found out that issue causing this error is from kotlin. I am not really sure what is the root cause though. After I change back to standard project, it successfully compile
Add this option to your app build.gradle file, this works for me in my project
android {
// ...
dexOptions {
javaMaxHeapSize "4g"
}
// ...
}

CIRCULAR REFERENCE:java.lang.NullPointerException from DexFileReader

I attempted to upgrade my build environment to Gradle 4.4 today, and ran into the following error while attempting build an APK:
[CIRCULAR REFERENCE:java.lang.NullPointerException]
Caused by: java.lang.NullPointerException
at com.android.tools.r8.dex.DexFileReader$AttributesAndAnnotations.<init>(DexFileReader.java:1129)
at com.android.tools.r8.dex.DexFileReader.addClassDefsTo(DexFileReader.java:682)
at com.android.tools.r8.dex.ApplicationReader$ClassReader.lambda$readDexSources$0(ApplicationReader.java:213)
at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
I then attempted to build using Gradle 4.5, and am seeing the same error. This application builds fine using Gradle 4.1, but a problem I reported separately is forcing me to upgrade at a time when I can't afford to chase down mysterious Dex errors.
Note: I disabled Proguard, but that had no effect.
In order to perform the Gradle upgrade, all I did was change the version in my gradle-wrapper.properties file; no other code or configuration changes were made.
Here is the full, very long stack trace, from the Gradle console, along with a few console lines -- which indicate that Gradle is attempting to complete the transformDexArchiveWithDexMerger task when this NullPointerException is thrown.
Removed unused resources: Binary resource data reduced from 6200KB to 6191KB: Removed 0%
:app:transformClassesWithDexBuilderForPlayStoreDebugprod
D8 is used to build dex.
:app:transformDexArchiveWithDexMergerForPlayStoreDebugprod
D8 is used to merge dex.
java.lang.NullPointerException
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:598)
at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:397)
at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:225)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:623)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:578)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
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:598)
at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
at com.android.tools.r8.utils.ThreadUtils.awaitFutures(ThreadUtils.java:21)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:115)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)
at com.android.tools.r8.D8.run(D8.java:156)
at com.android.tools.r8.D8.lambda$run$0(D8.java:71)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:58)
at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
at com.android.tools.r8.D8.run(D8.java:67)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:106)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:36)
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)
Suppressed: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006)
... 16 more
[CIRCULAR REFERENCE:java.lang.NullPointerException]
Caused by: java.lang.NullPointerException
at com.android.tools.r8.dex.DexFileReader$AttributesAndAnnotations.<init>(DexFileReader.java:1129)
at com.android.tools.r8.dex.DexFileReader.addClassDefsTo(DexFileReader.java:682)
at com.android.tools.r8.dex.ApplicationReader$ClassReader.lambda$readDexSources$0(ApplicationReader.java:213)
at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
It turned out that this was due to our use of the 9.0.0-SNAPSHOT version of the Butterknife plugin.
When we switched from this:
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
... to an older version that builds for us:
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
... the CIRCULAR REFERENCE NullPointerException Dex error went away.
Moral of the story: stick with stable, specific versions of your Gradle plugins.

"Execution of compression failed" error when building project in Android Studio 3.1

I'm trying to build https://github.com/neural-nuts/Cam2Caption in Android Studio 3.1 Preview, but either I use very old build.gradle, or it dies with
Error:Execution failed for task ':Application:packageDebug'.
Execution of compression failed.
this happens after doing a project clean, or a rebuild. OSX, latest most-everything. I'm using what I think is a default latest-and-greatest build.gradle
classpath 'com.android.tools.build:gradle:3.0.0'
...
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 26
targetSdkVersion 26
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
....
compile "com.android.support:support-v4:26.1.0"
compile "com.android.support:support-v13:26.1.0"
compile "com.android.support:cardview-v7:26.1.0"
compile "com.android.support:appcompat-v7:26.1.0"
With stacktrace, I get
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Application:packageDebug'.
> java.io.IOException: Execution of compression failed.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Application:packageDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.tooling.BuildException: java.io.IOException: Execution of compression failed.
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:241)
at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236)
at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197)
at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:449)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 29 more
Caused by: java.lang.RuntimeException: java.io.IOException: Execution of compression failed.
Caused by: java.io.IOException: Execution of compression failed.
at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:431)
at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1749)
at com.android.apkzlib.zip.ZFile.hasPendingChangesWithWait(ZFile.java:2623)
at com.android.apkzlib.zfile.ApkZFileCreator.hasPendingChangesWithWait(ApkZFileCreator.java:180)
at com.android.builder.internal.packaging.IncrementalPackager.hasPendingChangesWithWait(IncrementalPackager.java:319)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:672)
at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
Suppressed: java.io.IOException: Failed to obtain compression information for entry
at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1727)
at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1741)
at com.android.apkzlib.zip.ZFile.update(ZFile.java:904)
at com.android.apkzlib.zip.ZFile.close(ZFile.java:1196)
at com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:189)
at com.google.common.io.Closer.close(Closer.java:216)
at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:332)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:678)
at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
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: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1722)
... 16 more
Caused by: java.lang.IllegalArgumentException: Self-suppression not permitted
at com.android.apkzlib.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:72)
at com.android.apkzlib.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:54)
Caused by: java.lang.OutOfMemoryError: Java heap space
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:425)
... 9 more
[CIRCULAR REFERENCE:java.lang.IllegalArgumentException: Self-suppression not permitted]
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
I also ran into this problem. This happened because I included a very large zip file in the assets. So the JVM didn't had enough memory to build the project. I fixed this issue by adding dexoptions in app build.gradle
android {
dexOptions {
javaMaxHeapSize "4g"
}
}
And increasing JVM heap size
org.gradle.jvmargs=-Xmx4608M
like this. Go to gradle.properties to find this option.
This happened to me all the sudden on macOS. In my case the error went away after I restarted my computer.. weird.

Categories

Resources