intelliJ 2021.1 EAP 혹은 안드로이드 스튜디오 4.1.3 Rosetta2를 사용한 환경에서
Android Room을 사용한 프로젝트를 빌드하면
다음과 같은 오류로 빌드가 되지 않는다.
Caused by: java.lang.ExceptionInInitializerError at androidx.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:82) at androidx.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:57) at androidx.room.RoomProcessor$DatabaseProcessingStep.process(RoomProcessor.kt:134) at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330) at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181) at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt) at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:161) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068) at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:78) ... 30 more 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:68) ... 45 more
Room 프로젝트가 참조하고 있는 sqlite 라이브러리가 m1용 아니라서 생긴다.
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-rxjava2:$room_version") { exclude(group:'org.xerial') } testImplementation ("androidx.room:room-testing:$room_version") { exclude(group:'org.xerial') } implementation 'org.xerial:sqlite-jdbc:3.34.0'
요렇게 수정해주면 빌드가 된다.