'Failed to compile unsupported use of invokespecial

I'm trying to rebuild my project which I've written in JAVA but it has constantly failed with the error

[CIRCULAR REFERENCE:com.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial]

I've tried

  • Invalidating cache
  • cleaning and rebuilding
  • using ./gradlew build --stacktrace --info command

but without success.

Exception is

Caused by: com.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial

StackTrace is:

        Error: C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\9e0510f5b282f4ccf582e5c750563fca\jetified-je-18.3.12.jar:com/sleepycat/persist/impl/CollectionProxy$TreeSetProxy.class, java.lang.Object com.sleepycat.persist.impl.CollectionProxy$TreeSetProxy.bdbGetField(java.lang.Object, int, int,    boolean), Failed to compile unsupported use of invokespecial
    Stack trace:
    com.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial
    at com.android.tools.r8.errors.a.a(:7)
    at com.android.tools.r8.ir.conversion.O.b(:58)
    at com.android.tools.r8.ir.conversion.O.a(:104)
    at com.android.tools.r8.ir.conversion.O.a(:53)
    at com.android.tools.r8.graph.C.b(:43)
    at com.android.tools.r8.ir.conversion.O.b(:35)
    at com.android.tools.r8.utils.S0.a(:10)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:322)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
    at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:66)
    at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:36)
    at com.android.tools.r8.utils.S0.a(:3)
    at com.android.tools.r8.ir.conversion.O.a(:10)
    at com.android.tools.r8.D8.d(:29)
    at com.android.tools.r8.D8.b(:1)
    at com.android.tools.r8.utils.W.a(:30)
    at com.android.tools.r8.D8.run(:11)
    at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:116)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform.process(DexingTransform.kt:296)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform.processNonIncrementally(DexingTransform.kt:243)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform.doTransform(DexingTransform.kt:153)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform.access$doTransform(DexingTransform.kt:69)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform$transform$1.invoke(DexingTransform.kt:104)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform$transform$1.invoke(DexingTransform.kt:69)
    at com.android.build.gradle.internal.tasks.BlocksUtilsKt.recordArtifactTransformSpan(BlocksUtils.kt:33)
    at com.android.build.gradle.internal.dependency.BaseDexingTransform.transform(DexingTransform.kt:100)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformer.transform(DefaultTransformer.java:189)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory$TransformerExecution.execute(DefaultTransformerInvocationFactory.java:332)
    at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:63)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
    at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
    at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
    at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
    at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
    at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
    at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
    at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:153)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:67)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:41)
    at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
    at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
    at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
    at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
    at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
    at java.util.Optional.orElseGet(Optional.java:267)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
    at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
    at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
    at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory$2.lambda$call$2(DefaultTransformerInvocationFactory.java:200)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory.fireTransformListeners(DefaultTransformerInvocationFactory.java:269)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory.access$300(DefaultTransformerInvocationFactory.java:79)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory$2.call(DefaultTransformerInvocationFactory.java:178)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory$2.call(DefaultTransformerInvocationFactory.java:175)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory.lambda$doTransform$0(DefaultTransformerInvocationFactory.java:175)
    at org.gradle.api.internal.artifacts.transform.ImmutableTransformationWorkspaceProvider.lambda$withWorkspace$0(ImmutableTransformationWorkspaceProvider.java:81)
    at org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess.withFileLock(LockOnDemandCrossProcessCacheAccess.java:90)
    at org.gradle.cache.internal.DefaultCacheAccess.withFileLock(DefaultCacheAccess.java:181)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.withFileLock(DefaultPersistentDirectoryStore.java:172)
    at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.withFileLock(DefaultCacheFactory.java:196)
    at org.gradle.api.internal.artifacts.transform.ImmutableTransformationWorkspaceProvider.withWorkspace(ImmutableTransformationWorkspaceProvider.java:76)
    at org.gradle.api.internal.artifacts.transform.AbstractCachingTransformationWorkspaceProvider.lambda$withWorkspace$0(AbstractCachingTransformationWorkspaceProvider.java:56)
    at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4718)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3445)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2194)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2153)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2043)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3851)
    at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4713)
    at org.gradle.api.internal.artifacts.transform.AbstractCachingTransformationWorkspaceProvider.withWorkspace(AbstractCachingTransformationWorkspaceProvider.java:55)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory.doTransform(DefaultTransformerInvocationFactory.java:175)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory.access$000(DefaultTransformerInvocationFactory.java:79)
    at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory$1.invoke(DefaultTransformerInvocationFactory.java:141)
    at org.gradle.api.internal.artifacts.transform.CacheableInvocation$1.invoke(CacheableInvocation.java:58)
    at org.gradle.api.internal.artifacts.transform.TransformationNode$ChainedTransformationNode$1.lambda$transform$0(TransformationNode.java:226)
    at org.gradle.internal.Try$Success.flatMap(Try.java:157)
    at org.gradle.api.internal.artifacts.transform.TransformationNode$ChainedTransformationNode$1.transform(TransformationNode.java:225)
    at org.gradle.api.internal.artifacts.transform.TransformationNode$ArtifactTransformationStepBuildOperation.call(TransformationNode.java:267)
    at org.gradle.api.internal.artifacts.transform.TransformationNode$ArtifactTransformationStepBuildOperation.call(TransformationNode.java:247)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.api.internal.artifacts.transform.TransformationNode$ChainedTransformationNode.execute(TransformationNode.java:222)
    at org.gradle.execution.plan.WorkNodeExecutor.execute(WorkNodeExecutor.java:27)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.lang.Thread.run(Thread.java:748)
    Suppressed: java.util.concurrent.ExecutionException: com.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:552)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:513)
        at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:86)
        at com.android.tools.r8.utils.S0.a(:14)
        at com.android.tools.r8.utils.S0.a(:9)
        ... 121 more
    [CIRCULAR REFERENCE:com.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial]
        Caused by: com.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial
    at com.android.tools.r8.r.n.A.a(:177)
    at com.android.tools.r8.ir.conversion.o.a(:153)
    at com.android.tools.r8.ir.conversion.N.a(:133)
    at com.android.tools.r8.graph.l.a(:93)
    at com.android.tools.r8.graph.l.a(:71)
    at com.android.tools.r8.graph.l.buildIR(:1)
    at com.android.tools.r8.graph.C0.buildIR(:1)
    at com.android.tools.r8.graph.T.a(:152)
    at com.android.tools.r8.ir.conversion.O.a(:412)
    at com.android.tools.r8.ir.conversion.O.b(:53)

And dependencies:

 implementation project(path: ':dialogBox')
 implementation project(path: ':ckChangeLog')
 implementation fileTree(include: ['*.jar'], dir: 'libs')
 implementation 'androidx.legacy:legacy-support-v4:1.0.0'
 implementation 'com.google.android.material:material:1.3.0-alpha01'
 implementation 'androidx.appcompat:appcompat:1.1.0'
 implementation 'androidx.recyclerview:recyclerview:1.1.0'
 implementation 'androidx.preference:preference:1.1.1'
 implementation 'androidx.multidex:multidex:2.0.1'
 implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
 implementation 'com.mohamadamin:persianmaterialdatetimepicker:1.2.1'
 implementation 'com.intuit.sdp:sdp-android:1.0.6'
 implementation 'de.codecrafters.tableview:tableview:2.5.0'
 implementation 'com.android.volley:volley:1.1.1'
 implementation 'com.google.code.gson:gson:2.8.6'
 implementation 'com.google.code.ksoap2-android:ksoap2-android:3.6.4'
 implementation 'com.github.d-max:spots-dialog:0.7@aar'
 implementation 'com.mindorks.android:prdownloader:0.6.0'
 implementation 'org.jpos:jpos:2.1.4'
 implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
 implementation 'com.squareup.retrofit2:retrofit:2.9.0'
 implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2'
 implementation 'com.daimajia.androidanimations:library:2.3@aar'
 implementation 'com.daimajia.easing:library:2.1@aar'
 implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
 implementation 'org.greenrobot:essentials:3.0.0-RC1'
 implementation 'com.google.guava:guava:28.1-jre'
 implementation 'org.apache.commons:commons-lang3:3.10'

Gradle version:

        classpath 'com.android.tools.build:gradle:4.0.0'


Solution 1:[1]

If you don't use je library in your project anywhere, find the dependency that brought it in and exclude it there. That's how I solved mine. Specifically, it's jpos library that brought it in. Use this

implementation('org.jpos:jpos:2.1.4') {
        exclude group: 'junit', module: 'junit' 
        exclude group: 'com.sleepycat', module: 'je'
    } 

Solution 2:[2]

I faced a similar error, for me it caused by the fact that i still had android.enableR8 = false in my gradle.properties file. From gradle 4.0 you need to remove it and enable R8.

Solution 3:[3]

The code in jetified-je-18.3.12.jar use an invokestatic instruction to target a virtual member. D8 and R8 currently does not support translating this to DEX, as there is no DEX equivalent of this.

This is a known issue tracked as issue 157969878.

Solution 4:[4]

In My case, removed the below proguard line, and it's working!!

-allowaccessmodification

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 odifek
Solution 2 Shirane85
Solution 3 sgjesse
Solution 4 axita.savani