NoSuchMethodError : No virtual method noBackupDirectory : andriodx.work on Android.mk (AOSP App - Android 10)
NoSuchMethodError : No virtual method noBackupDirectory : andriodx.work on Android.mk (AOSP App - Android 10)
在 Android.mk 上使用 androidx.work aar 时出现以下运行时崩溃。我想在 Android 10 AOSP 平台应用程序中使用 Android Workmanager。
11-13 12:47:10.805 6236 6236 E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method noBackupDirectory(Z)Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder; in class Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder; or its super classes (declaration of 'androidx.sqlite.db.SupportSQLiteOpenHelper$Configuration$Builder' appears in /system/priv-app/RemoteVoiceInput/RemoteVoiceInput.apk)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkDatabase.create(WorkDatabase.java:127)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkDatabase_Impl.createOpenHelper(WorkDatabase_Impl.java:254)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.room.RoomDatabase.init(RoomDatabase.java:159)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:852)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkDatabase.create(WorkDatabase.java:154)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:236)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:211)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:190)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.WorkManager.initialize(WorkManager.java:210)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.access00(ActivityThread.java:219)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
11-13 12:47:10.806 4200 4200 I AvrcpMediaPlayerList: setActivePlayer(): setting player to com.google.android.music
11-13 12:47:10.820 3880 3908 W RescueParty: Noticed 4 events for UID 1000 in last 2 sec
11-13 12:47:10.822 4200 4200 D AvrcpGPMWrapper: Metadata currently out of sync for Google Play Music
示例 Andriod.mk 以包含 androidx.work
LOCAL_STATIC_JAVA_LIBRARIES := \
androidx.room_room-runtime \
androidx.lifecycle_lifecycle-livedata \
androidx.lifecycle_lifecycle-service \
androidx.paging_paging-runtime
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
work-runtime-2.4.0
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
work-runtime-2.4.0:libs/work-runtime-2.4.0.aar
您还需要 androidx.sqlite
的最新版本。这就是您看到异常的原因。
在 Android.mk 上使用 androidx.work aar 时出现以下运行时崩溃。我想在 Android 10 AOSP 平台应用程序中使用 Android Workmanager。
11-13 12:47:10.805 6236 6236 E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method noBackupDirectory(Z)Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder; in class Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder; or its super classes (declaration of 'androidx.sqlite.db.SupportSQLiteOpenHelper$Configuration$Builder' appears in /system/priv-app/RemoteVoiceInput/RemoteVoiceInput.apk)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkDatabase.create(WorkDatabase.java:127)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkDatabase_Impl.createOpenHelper(WorkDatabase_Impl.java:254)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.room.RoomDatabase.init(RoomDatabase.java:159)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:852)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkDatabase.create(WorkDatabase.java:154)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:236)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:211)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:190)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.WorkManager.initialize(WorkManager.java:210)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.access00(ActivityThread.java:219)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
11-13 12:47:10.805 6236 6236 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
11-13 12:47:10.806 4200 4200 I AvrcpMediaPlayerList: setActivePlayer(): setting player to com.google.android.music
11-13 12:47:10.820 3880 3908 W RescueParty: Noticed 4 events for UID 1000 in last 2 sec
11-13 12:47:10.822 4200 4200 D AvrcpGPMWrapper: Metadata currently out of sync for Google Play Music
示例 Andriod.mk 以包含 androidx.work
LOCAL_STATIC_JAVA_LIBRARIES := \
androidx.room_room-runtime \
androidx.lifecycle_lifecycle-livedata \
androidx.lifecycle_lifecycle-service \
androidx.paging_paging-runtime
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
work-runtime-2.4.0
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
work-runtime-2.4.0:libs/work-runtime-2.4.0.aar
您还需要 androidx.sqlite
的最新版本。这就是您看到异常的原因。