Android Kotlin Room database, build error “A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution” on Android Studio Preview Apple M1

Component used: Room

Version used: 2.3.0

Devices/Android versions reproduced on: MacBook Pro M1 chip


Build failed on Apple M1 with Room database 2.3.0

Execution failed for task ':app:kaptDebugKotlin'.

> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction

   > java.lang.reflect.InvocationTargetException (no error message)

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Solution:

  implementation "androidx.room:room-runtime:2.3.0"

  annotationProcessor "androidx.room:room-compiler:2.3.0"

1. You can use Alpha Release version of room: 

implementation "androidx.room:room-runtime:2.4.0-alpha04"

annotationProcessor "androidx.room:room-compiler:2.4.0-alpha04"

Room Database Alpha Release version 2.4.0-alpha04 

2. Also updated project level build Gradle with latest Kotlin plugin version and latest Gradle plugin. (Need to update this because I was facing some error related to apply plugin: 'kotlin-android')

buildscript {
//    ext.kotlin_version = '1.3.61'
    ext.kotlin_version = '1.5.30'
    repositories {
        google()
        jcenter()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath 'com.android.tools.build:gradle:4.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

 

Check detailed log here:

> Task :app:kaptDebugKotlin

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:

    /Users/pradiptilala/.gradle/caches/transforms-2/files-2.1/a6ee74fb178b3ea5a892efce09fbf14f/jetified-kotlin-stdlib-jdk7-1.3.61.jar (version 1.3)

    /Users/pradiptilala/.gradle/caches/transforms-2/files-2.1/120c1f3b8c4010532adc0c31034c2e5b/jetified-kotlin-stdlib-1.4.0.jar (version 1.4)

    /Users/pradiptilala/.gradle/caches/transforms-2/files-2.1/ce684c39ae6924170520b6f45161379f/jetified-kotlin-stdlib-common-1.4.0.jar (version 1.4)

w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

> Task :app:kaptDebugKotlin FAILED

java.lang.IllegalStateException: failed to analyze: java.lang.reflect.InvocationTargetException

at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:56)

at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:182)

at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)

at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)

at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)

at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)

at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)

at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:566)

at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)

at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)

at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.base/java.security.AccessController.doPrivileged(Native Method)

at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)

at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)

at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)

at java.base/java.security.AccessController.doPrivileged(Native Method)

at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)

at java.base/java.lang.Thread.run(Thread.java:834)

Caused by: java.lang.reflect.InvocationTargetException

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:566)

at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:76)

at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)

at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:224)

at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:187)

at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:98)

at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:97)

at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:107)

at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)

at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:557)

at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82)

at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)

at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:548)

at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177)

... 23 more

Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.ExceptionInInitializerError

at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:992)

at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896)

at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222)

at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1335)

at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)

at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1157)

... 40 more

Caused by: java.lang.ExceptionInInitializerError

at androidx.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:82)

at androidx.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:57)

at androidx.room.RoomProcessor$DatabaseProcessingStep.process(RoomProcessor.kt:134)

at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)

at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)

at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)

at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)

at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980)

... 45 more

Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64

at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:333)

at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:64)

at androidx.room.verifier.DatabaseVerifier.<clinit>(DatabaseVerifier.kt:68)

... 53 more

Execution failed for task ':app:kaptDebugKotlin'.

> Internal compiler error. See log for more details


Parcelize annotations from package 'kotlinx.android.parcel' are deprecated. Change package to 'kotlinx.parcelize'

Parcelize annotations from package 'kotlinx.android.parcel' are deprecated. Change package to 'kotlinx.parcelize'

I was using import statement like below when I was getting this warning
import kotlinx.android.parcel.Parcelize
Finally, replace old import with new import
import kotlinx.parcelize.Parcelize
Update to latest kotlin version - 1.4.20 and use below plugin

apply plugin: 'kotlin-parcelize'

Popular Posts