编译项目报错:
Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64
原因:
使用M1 处理器的mac,
room当前版本的room library还没支持.
- 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'
但升级后,需要
androidCompileSdkVersion
升级到30/31才可以。
若不想升级SDK版本.
可以使用Room2.3.0版本
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"
allprojects {
repositories {
// ...
}
// ADD THE FOLLOWING
configurations.all {
resolutionStrategy {
force 'org.xerial:sqlite-jdbc:3.34.0'
}
}
}
然后强制设置jdbc版本为支持M1的版本。