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

AndroidJdbcAndroid Room

Android Problem Overview


I am using Android Studio [Android Studio Arctic Fox | 2020.3.1 Patch 1]

My room library version is [2.3.0]
Used Gradle version [7.0.1]
Also added kapt 'org.xerial:sqlite-jdbc:3.36.0.1'


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:71)

How to solve this error?

SOLUTION Use Room Version: 2.4.0-alpha03 or later.

Android Solutions


Solution 1 - Android

If you are using Apple M1 chip

One of the release notes they have mentioned by jetpack (Version 2.4.0-alpha03 )

  • Fixed an issue with Room’s SQLite native library to support Apple’s M1 chips.

Change Version to 2.4.0-alpha03 or above

implementation "androidx.room:room-runtime:2.4.0-alpha03"
annotationProcessor "androidx.room:room-compiler:2.4.0-alpha03"
kapt 'androidx.room:room-compiler:2.4.0-alpha03'

Reference

https://developer.android.com/jetpack/androidx/releases/room#version_240_2

Solution 2 - Android

Update(26 October 2021) - it seems that Room got fixed in the latest updates, Therefore you may consider updating Room to the latest version : ---- 2.4.0-alpha03 ---- or above

For those who are facing this problem, you can simply add this line before the room-compiler as a workaround now:

kapt "org.xerial:sqlite-jdbc:3.34.0"

If the mentioned workaround not working, I recommend using this workaround instead, adding it to the root build.gradle. This will force using the given dependency in the whole project:

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

Solution 3 - Android

Room [2.4.0-alpha04] fixed this issues.

And remove kapt "org.xerial:sqlite-jdbc:3.34.0"

Solution 4 - Android

Here is what worked for me:

Change room version to 2.3.0 in app-level build.gradle

def room_version = "2.3.0" // for Room
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:$room_version"

In project-level build.gradle, add the following configuration in allprojects

allprojects {
    repositories {
        // ...
    }

    // ADD THE FOLLOWING
    configurations.all {
        resolutionStrategy {
            force 'org.xerial:sqlite-jdbc:3.34.0'
        }
    }
}

Clean & rebuild your project :)

Ref: this comment on Google IssueTracker

Solution 5 - Android

We used JDK 11 and we had to move from default JDK to version >= 11.0.13. And that fixed build issues on M1.

Solution 6 - Android

Room fixed this issues on Version 2.4.0-alpha03

Fixed an issue with Room’s SQLite native library to support Apple’s M1 chips.

Update: The room latest version is "2.4.2"

val roomVersion = "2.4.2"
implementation("androidx.room:room-runtime:$roomVersion")
annotationProcessor("androidx.room:room-compiler:$roomVersion")

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRomanView Question on Stackoverflow
Solution 1 - AndroidArun NSView Answer on Stackoverflow
Solution 2 - Androidshahar keysarView Answer on Stackoverflow
Solution 3 - AndroidRomanView Answer on Stackoverflow
Solution 4 - AndroidUtsav BarnwalView Answer on Stackoverflow
Solution 5 - AndroidandudeView Answer on Stackoverflow
Solution 6 - AndroidAlan YuanView Answer on Stackoverflow