我的场景:
1.Mac电脑,M1芯片
2.新工程项目,没有任何改动
报错:
解决办法
在Google的IssueTracker里找到的
总结:room没有适配M1,需要对room的引用进行修改
kapt("org.xerial:sqlite-jdbc:3.34.0") //追加这条
kapt("androidx.room:room-compiler:2.3.0-beta01")
或者
def room_version = "2.3.0-alpha03"
implementation("androidx.room:room-runtime:$room_version") {
exclude(group:'org.xerial')
}
kapt("androidx.room:room-compiler:$room_version"){
exclude(group:'org.xerial')
}
implementation("androidx.room:room-ktx:$room_version"){
exclude(group:'org.xerial')
}
implementation 'org.xerial:sqlite-jdbc:3.34.0'
原因:
大佬的回复:
大佬A:
Room uses https://github.com/xerial/sqlite-jdbc a JDBC library for SQLite, can you please file a bug in https://github.com/xerial/sqlite-jdbc asking to support the aarch64 architecture in the new Mac + M1 Chip?
I don’t have a M1 machine to try this out but my guess is they simply don’t have yet a compiled SQLite native lib for the aarch64.
大佬A:
By the way, I imagine you can workaround this using a JDK x86/x64 version + Rosetta that would make the JNI layer load the right native library.
大佬B:
Yes, Apple Silicon is supported by this pull request https://github.com/xerial/sqlite-jdbc/pull/558, but not released yet.
Hope to be supported in the next version of Room. Thanks!