Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 657
Roman Avatar asked Aug 22 '21 19:08

Roman


4 Answers

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

like image 116
Arun NS Avatar answered Oct 18 '22 04:10

Arun NS


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'
        }
    }
}

like image 26
shahar keysar Avatar answered Oct 18 '22 04:10

shahar keysar


Room [2.4.0-alpha04] fixed this issues.

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

like image 18
Roman Avatar answered Oct 18 '22 04:10

Roman


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

like image 15
Utsav Barnwal Avatar answered Oct 18 '22 02:10

Utsav Barnwal