Problem

안드로이드에서 고유 ID를 확인하기 위해서 ANDROID_ID를 이용할 수 있다. 만약 암호화 관련 처리가 필요한 경우 키의 일부를 ANDROID_ID를 조합하여 사용하고 있는 경우 문제가 발생할 수 있다. 나는 sqlcipher 처리 관련된 처리에서 문제를 경험했었고 아래와 같이 file is not a database오류가 발생했었다.

Fatal Exception: java.lang.RuntimeException: Unable to create application ...: net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6657)
       at android.app.ActivityThread.access$1300(ActivityThread.java:219)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7557)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:937)

Solution

ANDROID_ID는 안드로이드 8.0이상 부터는 앱 사이닝 키와 결합하여 유니크 아이디가 결정된다. 즉, 서명한 키 별로 결과가 다를 수 있다. 만약 플레이 스토어에 재 사이닝된 apk의 경우와 이미 플레이스토어를 통해 설치된 앱을 다른 경로로 업데이트 받은 경우 또는 반대의 경우도 같은 에러가 발생할 수 있다.

On Android 8.0 (API level 26) and higher versions of the platform, a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user, and device1.

References