160

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.

5
  • Presumably, you need to get rid of kapt 'org.xerial:sqlite-jdbc:3.36.0.1'. It is not an annotation processor and Room does not use that library. Commented Aug 22, 2021 at 19:41
  • I have removed that line and tried but still error. Commented Aug 23, 2021 at 8:49
  • Same question basically as stackoverflow.com/questions/67758513/…. The bug tracker for the issue is here: issuetracker.google.com/issues/174695268#comment9 Commented Sep 10, 2021 at 13:49
  • 1
    Thanks, It woks for me. Commented Dec 17, 2021 at 14:48
  • anyone has any idea, why does difference in a computer chip has to do with how the library behaves. Commented Jun 24, 2022 at 10:47

8 Answers 8

199

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

Sign up to request clarification or add additional context in comments.

8 Comments

This one works for me. So for anyone who get main error message about "A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution Room Database" but have to run --stacktrace to see real error "No native library is found for os.name=Mac and os.arch=aarch64".
2.4.0-alpha05 also works.
This is weird but works. Yet dont you think being in Alpha would cause any problems in future or problems with live production apps. Thatt working with teams? @Abhimanyu
The same resolves the problem when the chip is Apple M1 Pro
Thank you. For today version 2.4.1 works well.
|
77

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

1 Comment

I was facing the issue even after updating room to version 2.5.1. Adding this force resolution strategy did solve this issue finally!
23

Room [2.4.0-alpha04] fixed this issues.

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

2 Comments

Thanks, this worked for me as well. I don't really like the fact that my project randomly breaks like this without me having made any changes. Feels very destabilizing.
2.4.2 is stable at this moment and I confirm this works on M1 Pro chipset.
22

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

1 Comment

this is really help if anyone can't update room version from 2.3.0 to 2.4.0 alpha, thanks man :)) @Utsav Barnwal
16

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")

Comments

3

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

Comments

2

Macbook Pro - Chip M2 Pro 2023 model - macOS Sonoma - I solved with this info:

def room_version = "2.4.0-alpha05"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

Comments

1

Macbook Air M1 - I solved with this step:

Upgrade kotlin at 1.6.0 version (search kotlin version in your project) Upgrade version.androidx.room from 2.3.0 to version.androidx.room=2.4.0 because of this:

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

Only my case: I added this lib

implementation("androidx.room:room-paging:2.4.0-alpha05")

If you use @FlowPreview, change this to @OptIn(FlowPreview::class)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.