개인 프로젝트 오류 해결 과정

이승우·2023년 4월 26일
1

오랜만에 개인 프로젝트를 새로운 m1 맥북에서 열어보았다... 행복하게 에러 없이 열릴 것이라 기대했지만 아니었고 아래와 같은 에러가 발생했다. 🥲

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)
	... 52 more

1. targetSdkVersion update 👍

targetSdkVersion이 29로 되어 있는데, Google Play의 권장 사항이 31이 이상이기 때문에 업데이트를 하였다. 이건 에러의 직접적인 원인이 되지는 않는다.

2. Android 12 android: exported update 👍

API 31로 업데이트를 한 뒤, 발생하는 에러가 생겼다. Android 12 이상을 타겟으로 하는 앱에서는 AndroidManifest.xml에서 Activity, Service, Receiver 등에 exported 속성을 명시적으로 설정해야 한다는 것이다.

문서 참고 👉 https://developer.android.com/guide/topics/manifest/activity-element?hl=ko#exported

exported 속성은 앱에서 Activity, Service, Receiver에서 접근할 수 있으며, 외부 응용 프로그램에서 실행될 수 있는지 여부를 정의하는데 사용된다.

  • exported = true
    • 다른 애플리케이션의 구성 요소로 해당 컴포넌트를 실행할 수 있다.
  • exported = false
    • 같은 애플리케이션의 구성 요소 또는 사용자 ID가 같은 애플리케이션으로 실행할 수 있다.

아래와 같이 exported = true로 설정하여 해결하였다.

<application
        android:name="app.woovictory.memonote.app.MemoApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning"
        tools:targetApi="q">
        <activity
            android:name="app.woovictory.memonote.presentation.view.MainActivity"
            android:screenOrientation="portrait"
            android:exported="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

3. Room Error on M1 Macbook 👍

그럼에도 동일한 에러가 발생하였다. 에러 메시지를 조금 더 살펴보니 Sqlite 쪽에서 에러가 발생하고 있었다. 나는 Room만을 사용하고 있기에 Room이 내부에서 사용하는 Sqlite에서 에러가 발생한다는 걸 알 수 있었고, 확인을 해보니 M1 맥북에서 Room 라이브러리가 정상적으로 호환되지 않는다는 것을 알게 되었다.

따라서 Sqlite를 직접 의존성 추가해주면 해결되는 이슈였다.

kapt 'org.xerial:sqlite-jdbc:3.34.0'
compileOnly 'com.github.pengrad:jdk9-deps:1.0'

Sqlite만 추가해주면 Annotation Processing 과정에서 에러가 발생했다. 구글링을 해보니 의존성을 하나 더 추가해줘야 한다고 한다. 해결은 되었지만, 왜 되는 것인지 추후에 살펴볼 예정이다..

일단, 개인 프로젝트가 새로운 맥북에서 동작하는 것은 확인하였다. 하지만, 예전에 만든 프로젝트이기 때문에 라이브러리 버전이나 코드를 유지보수할 예정이다. 그러면서 Room 버전도 업데이트를 해야겠다.

화이팅해보자~!

Ref

profile
Android Developer

0개의 댓글