How can I solve this issue on Mac M1 Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64

Viewed 1438

I solved this issue with the code below in my build.gradle

  allprojects {
configurations.all {
    resolutionStrategy {
        force 'org.xerial:sqlite-jdbc:3.34.0'
      }
   }
 } 

But it has an effect on the project I am working on. for some reason, it is not working with room sql implemented on the project.

I get this error when i removed the code above.

Is there a better approach to solve this.

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:161)
at 

 

jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980) ... 39 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)
... 47 more
3 Answers

update your room library

   implementation "androidx.room:room-runtime:2.4.2"
   implementation "androidx.room:room-ktx:2.4.2"
   kapt "androidx.room:room-compiler:2.4.2"

Here is Reference

In my case updating to 2.4.2 only asking me to update the SDK version to 31 and more problem appears. I found alternative solution by selecting

Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle

Navigate to Gradle Project section and click Gradle JDK dropdown option field.

illustration

Select Liberica-1.8 (if it is not available in dropdown field, you can download and install here https://bell-sw.com/pages/downloads/).

Run the project again and voila!!

yeb run working on my case(my mac mini m1) =>>> implementation "androidx.room:room-runtime:2.4.2" implementation "androidx.room:room-ktx:2.4.2"

Related