OneSignal-Android-SDK
OneSignal-Android-SDK copied to clipboard
[Bug]: WorkManager needs to be initialized via a ContentProvider#onCreate() or an Application#onCreate().
What happened?
Our app occur this crash below recently. We didn't use WorkManager in the app, so we guess that OneSignal cause this issue maybe.
Caused by java.lang.IllegalStateException: WorkManager needs to be initialized via a ContentProvider#onCreate() or an Application#onCreate().
at androidx.work.impl.background.systemjob.SystemJobService.onCreate(SystemJobService.java:73)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4532)
at android.app.ActivityThread.access$100(ActivityThread.java:287)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2189)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:255)
at android.app.ActivityThread.main(ActivityThread.java:8212)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
The app dependence Snapchat-adskit sdk, which we found the code below in it's manifest file. In WorkManager document, it indicate that this can remove the default initializer. So, will it the reason cause the crash?
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="com.snap.appadskit.distribution.workmanager-init"
tools:node="remove" />
According to the WorkManager document, our Application class implements the Configuration.Provider interface and override it's getWorkManagerConfiguration function. Document link below
https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration
Steps to reproduce?
We are unable to reproduce it.
What did you expect to happen?
Fix this crash
OneSignal Android SDK version
Release 4.7.2
Android version
11
Specific Android models
* realme 6、realme 7、realme C3
* OPPO A94、OPPO F11、OPPO CPH 1989
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Hello thank you for reaching out. Do you think this is related to #1561?
Hi @CharlieZheng,
Looking at this issue again, it is not related to #1561.
It sounds like you are doing the 2 steps required for Custom WorkManager Configuration. com.snap.appadskit
is removing the default WorkManager Initializer and you mention you're doing step 2 of implementing the Configuration.Provider. Can you confirm this is what you want to do?
If this is done correctly, you should not get this error. Here is the source code where that exception is thrown. It is likely a Google library bug or edge case, as there are similar reports in their issue tracker.
As a result, your crash is not something the OneSignal SDK can fix.
But something else you can check is your version of androidx.work:work-runtime
which you can find in the Merged Manifest.
Closing issue due to no response. Please @ mention me if we need to revisit this issue.
We have an updated major release available for our Android SDK with many improvements and enhancements! Please refer to the migration guide for more information on upgrading.
Thanks!
@jennantilla Is this resolved in the Unity plugin as well? I migrated to the latest version but the issue still persists