尝试在安卓官方的APP示例 Now in Android (https://github.com/android/nowinandroid)中集成uni小程序sdk遇到了一些问题。参考uni官方集成教程(https://nativesupport.dcloud.net.cn/UniMPDocs/UseSdk/android.html),在Now in Android项目中集成了uni小程序的依赖库和资源文件,并修改了build.gradle.kts、AndroidManifes.xml等文件,编译成功。但是运行的时候,初始化uniMPSDK后,会提示以下错误:
FATAL EXCEPTION: main (Ask Gemini)
Process: com.google.samples.apps.nowinandroid.demo.debug:unimp0, PID: 9874
java.lang.RuntimeException: Unable to create application com.google.samples.apps.nowinandroid.NiaApplication: java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7510)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2416)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8705)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.
at androidx.work.impl.WorkManagerImpl.getInstance(WorkManagerImpl.java:170)
at androidx.work.WorkManager.getInstance(WorkManager.java:186)
at com.google.samples.apps.nowinandroid.sync.initializers.Sync.initialize(SyncInitializer.kt:28)
at com.google.samples.apps.nowinandroid.NiaApplication.onCreate(NiaApplication.kt:49)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1386)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7504)
从log看进程是unimp0,安卓uni小程序SDK中有使用WorkManager吗?需要怎么改才能在已经使用了WorkManager的安卓项目中使用uni小程序?
0 个回复