unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)
Asked Answered
A

17

237

I received this build error having updated my native android project to Android S (Pre release of android 12).

Googling for the error threw up no valuable hits. One hit from Netbeans a few years back and some Xamarin problems.

The stack trace is below :

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':dependencies:android:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':dependencies:android:kaptDebugKotlin'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:200)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:198)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:179)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
    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 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
    at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:336)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:142)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:94)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForAll(DefaultAsyncWorkTracker.java:80)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:68)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:563)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:540)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:523)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:108)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:271)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:260)
    at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:33)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:67)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:36)
    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.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:42)
    at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:159)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:72)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:43)
    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 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 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.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:187)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:179)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
    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 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.reflect.InvocationTargetException
    at org.jetbrains.kotlin.gradle.internal.KaptExecution.run(KaptWithoutKotlincTask.kt:288)
    at org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction.execute(KaptWithoutKotlincTask.kt:243)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63)
    at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
    at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60)
    at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
    ... 3 more
Caused by: java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)
    at com.sun.tools.javac.util.Assert.error(Assert.java:133)
    at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
    at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
    at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitVarDef(TypeAnnotations.java:1164)
    at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
    at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
    at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
    at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1042)
    at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
    at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
    at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:127)
    at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:152)
    at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
    at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
    at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
    at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:83)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:31)
    at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
    ... 28 more

Are there any steps I could take to overcome this problem?

Actinolite answered 12/7, 2021 at 8:46 Comment(4)
I encountered a similar error while using android-sdk with openjdk version 1.8.0_292. I switched java to alias to my installation of openjdk 11, as detailed by this post #12788257, and the issue went away for me. So if you're using openjdk 1.8 try switching to a version of openjdk 11.Oleate
Same here. It is related to compiling for Android 12 (uses-sdk android:targetSdkVersion="31")Marni
have you found soltion@Chris?Inalterable
I am also facing same issue. is there a way without switching to openjdk11 as that is causing another issue in my gradle files?Siple
D
325

This arises in Android builds from a combination of:

  • Using compileSdkVersion 31 (or maybe later),
  • With JDK8,
  • Having any Lambda style related code somewhere (else error may not happen).

The default android toolchains have moved to JDK11 now, you must use JDK11, at least if you change any of the Android API target versions to 31 (or later).


Path to update your gradle jdk in AS Arctic Fox:

Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK

Select 11 and build should be successful.

If this option does not exist, upgrade Android Studio.

Denticulation answered 20/9, 2021 at 7:25 Comment(11)
Equally File > Project structure > SDK Location > Gradle Settings works too.Actinolite
On a Mac: Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDKZero
@RaphaelPinel I had to update android studio to see those options.Incredulity
If you don't see 11 there click on what you have under Gradle JDK and select "Download JDK...". In the drop down that comes up select Version 11 and press download.Fatshan
I followed the instructions, but in Gradle, there is no Gradle JDK, or anything to select from. There is just "Gradle User Home"Wellmeaning
Making JDK 11 Worked for me, Thank.Shaving
When upgrading to Java 11, is it safe to leave sourceCompatibility, targetCompatibility, and jvmTarget pointing at Java 1.8?Apocarpous
Any idea on how to update the JDK on Visual Studio 2022 (Xamarin.Android App)?Sasin
Just a note, I needed to update Android Studio version to "Android Studio Chipmunk | 2021.2.1 Patch 2 for Mac" to see the JDK update option in "Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK"Cal
Is there any documentation to support the need for this?Resume
This option was not there. So I upgraded android studio, and then it built without any error.Karalynn
H
62

I was hitting this issue in a build container, but not when building through android studio.

The difference in the two environments was the JDK version. Android studio was using JDK 11, while the build container was using openjdk-8.

The fix was updating the container's JDK version to openjdk-11.

Hunt answered 21/7, 2021 at 16:58 Comment(3)
how do you checked container's JDK?Inalterable
I recommend below steps 1. Update to latest Android studio 2. To upgrade the JDK to 11 follow: #66449661Roussillon
To check the containers JDK just echo JAVA_HOME. It will depend on which container you are using but it may be possible to use an alternative JDK installed on the container by updating JAVA_HOME to point to the correct JDK installationMountebank
G
29

Android 12 seems to need JDK 11 +.

In Android Studio you can update the JDK from 8 to 11.

If you use any DevOps tools, you will also need to update the JDK to 11 otherwise it will not compile the debug build apk.

Gorgon answered 10/11, 2021 at 15:19 Comment(3)
Not sure. I have checked - a simple project with targetSdk=31 compiles using java 8Clay
This is odd. Sometimes it seems to work with Java 8, but when I just ran into the described issue, and updated to Java 11, the issue was gone. Thanks a lot for saving my time.Regurgitation
I can confirm it works with Java 14 as well.Iodometry
C
13

Very "manual" way for resolving/updating needed dependency (min. JDK 11 for building for API 31+):

before manual downloading read step 3. Easier automated way appeared in newest AS updates

  1. download JDK 11, e.g. from official site: https://www.oracle.com/java/technologies/downloads/ (but you need account) or from https://jdk.java.net/ (straight link to sub-site, there you can find links for Windows and Linux)
  2. unpack and place somewhere with know and accessible path, preferably next to old ones (if you don't know where - check in next step where is placed currently used JDK)
  3. then in Android Studio pick File -> Project Structure -> SDK Location tab on the left and in there you can find JDK Location labeled text field - put in here path to new version of JDK, then click "Apply" button. update: current/newest Android Studios (e.g. 2022.3.1) have "JDK location was moved to GradleSettings" label, which is clickable and opens Gradle window allowing to place path in GradleJDK: field on the bottom (and there is also "Download" option on dropdown list...)
  4. (optional) pick File -> Invalidate Caches / Restart and do "full restart", let AS to re-set all dependencies including basic new JDK dependency (step for just-to-be-shure, as "Apply" button in prev step should do it for you)
Chicago answered 23/10, 2021 at 13:19 Comment(0)
A
10

Android 31(compileSdkVersion) seems to need JDK 11 +.

In Android Studio you can update the JDK from 8 to 11.

File -> Project Structure -> Sdk Location -> Gradle Settings -> Gradle SDK

This works for me in Cordova, Flutter, ReactNative and Capacitor. Becouse one of my implementation had lambda expressions in its code.

Anemography answered 17/8, 2022 at 8:14 Comment(1)
I use Quasar (which uses Cordova) and my JDK was already in version 11. What worked for me was updating the Java Jdk from my system for version 11. For those who use Quasar will also need to update the new JDK bin pathGlanders
G
4

I faced same issue and I had to update Android studio. Now it is working with jdk 1.8.0_291 as well. I updated to Arctic fox 2020.3.1 version of Android studio

Garnetgarnett answered 26/8, 2021 at 5:14 Comment(2)
Once you update your Android Studio to Arctic fox, your jdk version for building app with your Android Studio will be updated to 11 automaticallyMicromho
This doesn't work. I fixed it by upgrading to OpenJDK 11.Marni
D
4

I encounter the same issue, it seems JDK8 is not compatible with Android-12's android.jar.

But Android-11s' worked.

Base on my demand, I change to compileOnly Android-11's android.jar and then I can successfully build my app.

Decuple answered 9/9, 2021 at 14:37 Comment(2)
Same issue. But I need to target Android 12. did you find any alternativeGorgon
@Gorgon Base on other answers, you can try to update related gradle jdk version to JDK11, it should work well with Android-12's android.jar. You can run gradle --version or gradlew --versionto see the current version.Decuple
F
4

For Visual studio for mac: Download and install java 11 from Microsoft, like this location: https://download.visualstudio.microsoft.com/download/pr/0df4ef07-5a9a-4fc2-8ae6-0b6731685d25/fb07059f75bd3916b490f2d266bc94c0/microsoft-jdk-11.0.12.7.1-macos-x64.pkg

Then Go to Tools->SDK Manager, locations tab, and make sure your java location is the location you have installed recently (ie mine: /Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home

then rebuild your project

Faxen answered 26/10, 2021 at 9:10 Comment(0)
B
4

In my case - the error turned out to be using an old version of Android Gradle Plugin (3.6.4), after update Unity to v2020.3.33 (also as 2021.3.0).

In one of the updates Unity - updated and version of Gradle, which was not compatible with the old version of the plugin.

Solution

  • Download Android 12 (API 31) - Unity automatically uses it as a Target API (Android 12L (API 32) is also possible - doesn't really matter)

  • Set Android Gradle Plugin version to 4.0.1 in the file baseProjectTemplate.gradle

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

  • Android Build Tools leave version 30.0.+ (as with 31 and above - so far incompatible with Unity)

Bosquet answered 15/4, 2022 at 15:50 Comment(0)
H
3

Users who are facing this error on appcenter can add the below environment variable into the build config.

JAVA_HOME: $(JAVA_HOME_11_X64)
Hadlee answered 8/6, 2022 at 9:0 Comment(2)
Which specific file is the build config?Kally
In AppCenter click on "Build configuration" -> Enable switch for "Environment variables". In Name filed "JAVA_HOME" - In value filed $(JAVA_HOME_11_X64).Daberath
G
1

If anyone is having this issue on Visual Studio 2019. then you have to update the Android SDK Manager (Tools > Android > Android SDK Manager) to Android 12

After the installation, of JDK 11, refer to the below link which contains all the steps.

https://github.com/xamarin/xamarin-android/wiki/JDK-11-Warning#visual-studio-2019

Gremlin answered 3/7, 2022 at 7:16 Comment(0)
B
1

This is adding to the answer that @top-master provided. When I ran my build using react-native run-android it failed but it would pass in Android Studio. It turns out that Android Studio was using a different JDK than was being used locally.

So, if that's the case for you, run ls -la /Library/Java/JavaVirtualMachines to see what JDK you have installed. Once I upgraded this to brew install --cask adoptopenjdk/openjdk/adoptopenjdk11 it worked.

Bojorquez answered 28/7, 2022 at 21:32 Comment(0)
P
1

I was getting the same error when building our Android app in Ionic Dashboard after updating compileSdkVersion to 31. The fix was to force Ionic to use Java v11 using this environment variable: https://ionic.io/docs/appflow/cookbook/override-java-version

Prevocalic answered 22/11, 2022 at 20:23 Comment(0)
P
0

In my case this error occurred due to data binding, in my layout file when I removed the the root tag, this error disappeared.

This may not be solution as we want to use data binding but this may help someone.

Perky answered 17/2, 2022 at 13:31 Comment(0)
A
0

For anyone still facing issue try my solution in build.gradle file project level :

classpath 'com.android.tools.build:gradle:4.1.3'
Anthurium answered 13/7, 2022 at 14:12 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Inconsumable
C
0

For me this error came up after downloading JDK 11 and upgrading flutter.

First start by following the instructions at https://mcmap.net/q/119491/-android-studio-no-option-to-change-gradle-jdk-path.

If that doesn't work, here's what fixed this error for me:

  1. Download JDK v11 from https://www.openlogic.com/openjdk-downloads and install is. Then make sure you set these configurations:
  • In android/build.gradle under buildscript set
buildscript {
    ext.kotlin_version = '1.7.10'
    ...
}
  • Also in android/build.gradle, update the dependencies to
dependencies {
    classpath 'com.android.tools.build:gradle:7.2.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    ...
}
  • In android/app/build.gradle update the dependencies to
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    ...
}
  • Also in android/app/build.gradle, under android update the compileSdkVersion and targetSdkVersion as such:
android {
    compileSdkVersion flutter.compileSdkVersion
    ...
}
defaultConfig {
    targetSdkVersion flutter.targetSdkVersion
    ...
}
  • Also in android/app/build.gradle, add or update:
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    ...
}

and

kotlinOptions {
    jvmTarget = '1.8'
}
  1. Set the JDK gradle will use in the Flutter app by following the instructions at https://mcmap.net/q/119491/-android-studio-no-option-to-change-gradle-jdk-path.

  2. In build.gradle I had code under 'repositories' that was binding to an earlier version of gradle, which I had to remove:

    allprojects {
        repositories {
          ...
          tasks.withType(JavaCompile).configureEach {
             javaCompiler = javaToolchains.compilerFor {
                languageVersion = JavaLanguageVersion.of(8)
             }
           }
        }
    }
    
  3. Remove all references to repositories that are using older versions of gradle:

jcenter()

and

maven { url 'https://maven.fabric.io/public' }

  1. From gradle.properties remove (if it exists):

android.enableR8=true

  1. From app/build.gradle remove (if it exists):

useProguard true

and

apply plugin: 'io.fabric'

Caelum answered 2/5, 2023 at 16:25 Comment(0)
H
0

I just had this for a non-Android Java project when I started using jSpecify's NullMarked annotation. Several thorough cleans (mvn clean and git clean -Xfd) did not help, only a git revert of the commit adding this annotation helped.

This was for a Java8 project.

Hijack answered 15/5, 2023 at 13:20 Comment(3)
Sorry for the trouble. Do you happen to know if you saw this only when using @NullMarked on a method, or did it happen even when you used it on a class or package? We've encountered the problem before with method-level annotations, but we've hoped that those would be rare. See github.com/jspecify/jspecify/wiki/…, but I have been hoping to expand that sometime.Flournoy
@ChrisPovirk: it was indeed a method-level annotation. Thanks for confirming this. If a class/package level use-case occurs, would you like feedback here or somewhere else ?Hijack
Thanks, and thanks for letting us know about this in the first place. As for future reports: It looks like Stack Overflow will email me if you post here, but the ideal place to report would be github.com/jspecify/jspecify/issues/new so that it goes directly in front of the whole group's eyes.Flournoy

© 2022 - 2024 — McMap. All rights reserved.