Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: WorkManager is not initialized properly. #507

Open
1 task done
shefich opened this issue May 26, 2022 · 30 comments
Open
1 task done

[Bug]: WorkManager is not initialized properly. #507

shefich opened this issue May 26, 2022 · 30 comments

Comments

@shefich
Copy link

shefich commented May 26, 2022

What happened?

Th latest SDK version 3.0.2 gives me such error:
Non-fatal Exception: java.lang.Exception
AndroidJavaException : 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.

Steps to reproduce?

Install OneSignal SDK

What did you expect to happen?

Not to have this error

Unity version

2020.3.34

OneSignal Unity SDK version

3.0.2

Platform

Android

Relevant log output

androidx.work.impl.WorkManagerImpl.getInstance (androidx.work.impl.WorkManagerImpl)
androidx.work.WorkManager.getInstance (androidx.work.WorkManager)
com.onesignal.OSNotificationRestoreWorkManager.beginEnqueueingWork (com.onesignal.OSNotificationRestoreWorkManager)
com.onesignal.OneSignal.handleActivityLifecycleHandler (com.onesignal.OneSignal)
com.onesignal.OneSignal.init (com.onesignal.OneSignal)
com.onesignal.OneSignal.setAppId (com.onesignal.OneSignal)
com.onesignal.OneSignal.reassignDelayedInitParams (com.onesignal.OneSignal)
com.onesignal.OneSignal.provideUserConsent (com.onesignal.OneSignal)
com.unity3d.player.UnityPlayer.nativeRender (com.unity3d.player.UnityPlayer)
com.unity3d.player.UnityPlayer.access$300 (com.unity3d.player.UnityPlayer)
com.unity3d.player.UnityPlayer$e$1.handleMessage (com.unity3d.player.UnityPlayer$e$1)
android.os.Handler.dispatchMessage (android.os.Handler)
android.os.Looper.loop (android.os.Looper)
com.unity3d.player.UnityPlayer$e.run (com.unity3d.player.UnityPlayer$e)
UnityEngine.AndroidJNISafe.CheckException (UnityEngine.AndroidJNISafe)
UnityEngine.AndroidJavaObject._CallStatic (UnityEngine.AndroidJavaObject)
OneSignalSDK.OneSignalAndroid.set_PrivacyConsent (OneSignalSDK.OneSignalAndroid)
OneSignalInit.ReceivedUserConsent (OneSignalInit)
ConsentSystem.AcceptFullConsent (ConsentSystem)
UnityEngine.Events.UnityAction.Invoke (UnityEngine.Events.UnityAction)
UnityEngine.Events.UnityEvent.Invoke (UnityEngine.Events.UnityEvent)
UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1])
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.EventSystems.ExecuteEvents)
UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.StandaloneInputModule)
UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents (UnityEngine.EventSystems.StandaloneInputModule)
UnityEngine.EventSystems.StandaloneInputModule.Process (UnityEngine.EventSystems.StandaloneInputModule)
UnityEngine.EventSystems.StandaloneInputModule:Process (UnityEngine.EventSystems)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@gadzilka
Copy link

gadzilka commented Aug 25, 2022

I see the same issue in our Firebase Crashlytics on nova 3i (Android 9).
SDK 3.0.2
Unity 2020.3.36f1

Fatal Exception: 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:158)
       at androidx.work.WorkManager.getInstance(WorkManager.java:184)
       at com.onesignal.OSNotificationRestoreWorkManager.beginEnqueueingWork(OSNotificationRestoreWorkManager.java:48)
       at com.onesignal.OneSignal.handleActivityLifecycleHandler(OneSignal.java:968)
       at com.onesignal.OneSignal.init(OneSignal.java:845)
       at com.onesignal.OneSignal.setAppId(OneSignal.java:728)
       at com.onesignal.OneSignal.reassignDelayedInitParams(OneSignal.java:1174)
       at com.onesignal.OneSignal.onRemoteParamSet(OneSignal.java:882)
       at com.onesignal.OneSignal$7.complete(OneSignal.java:1115)
       at com.onesignal.OneSignalRemoteParams.processJson(OneSignalRemoteParams.java:206)
       at com.onesignal.OneSignalRemoteParams.access$100(OneSignalRemoteParams.java:12)
       at com.onesignal.OneSignalRemoteParams$1.onSuccess(OneSignalRemoteParams.java:151)
       at com.onesignal.OneSignalRestClient$5.run(OneSignalRestClient.java:292)
       at java.lang.Thread.run(Thread.java:784)

@shefich
Copy link
Author

shefich commented Sep 19, 2022

Still have this error. I tried 3.0.3 and 3.0.4.

Fatal Exception: 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:158) at androidx.work.WorkManager.getInstance(WorkManager.java:184) at com.onesignal.OSNotificationRestoreWorkManager.beginEnqueueingWork(OSNotificationRestoreWorkManager.java:48) at com.onesignal.OneSignal.handleActivityLifecycleHandler(OneSignal.java:975) at com.onesignal.OneSignal.init(OneSignal.java:852) at com.onesignal.OneSignal.setAppId(OneSignal.java:735) at com.onesignal.OneSignal.reassignDelayedInitParams(OneSignal.java:1181) at com.onesignal.OneSignal.onRemoteParamSet(OneSignal.java:889) at com.onesignal.OneSignal$7.complete(OneSignal.java:1122) at com.onesignal.OneSignalRemoteParams.processJson(OneSignalRemoteParams.java:211) at com.onesignal.OneSignalRemoteParams.access$100(OneSignalRemoteParams.java:12) at com.onesignal.OneSignalRemoteParams$1.onSuccess(OneSignalRemoteParams.java:156) at com.onesignal.OneSignalRestClient$5.run(OneSignalRestClient.java:279) at java.lang.Thread.run(Thread.java:780)

How can I fix the issue?

@shefich
Copy link
Author

shefich commented Nov 16, 2022

Steps to reproduce:

  1. Launch the app.
  2. Close the app.
  3. Launch it one more time(immidiately).
  4. Crash happens.

@Martin-Gonzalez90
Copy link

Same, I created one but I guess is the same issue
#558

@toseefhaiderkhansugguu
Copy link

i am facing this issue with latest Onesignal unity sdk i dont know what to do?
Screenshot 2022-11-30 at 5 00 08 PM

@jkasten2
Copy link
Member

jkasten2 commented Dec 1, 2022

Thanks for reporting, we looking for additional details to narrow down the cause of this issue. Can you fill out the requested details on this Github issue so we can try to find the root cause?
OneSignal/OneSignal-Android-SDK#1672

@shefich
Copy link
Author

shefich commented Dec 1, 2022

Either create and test "custom WorkManagerInitializer" by yourself, or give us an example script to use in Unity (not in Android Studio). We will test it and will give you results. For you and other people who are facing same crashes.

@toseefhaiderkhansugguu
Copy link

Either create and test "custom WorkManagerInitializer" by yourself, or give us an example script to use in Unity (not in Android Studio). We will test it and will give you results. For you and other people who are facing same crashes.

How can i create "custom WorkManagerInitializer" in unity at runtime? before One-singnal initialisation.

@shefich
Copy link
Author

shefich commented Dec 1, 2022

@toseefhaiderkhansugguu check the link provided by @jkasten2 and ask him once again. As I see more people (like me) don't understand how to fix or at least try to fix the issue.

@Martin-Gonzalez90
Copy link

Has anybody tried to increase the initOrder in the WorkerManagerInitializer? I had not time to test it
I guess by adding this piece in the AndroidManifest, then it should be merged.

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:exported="false"
            android:initOrder="100" 
            android:authorities="dk.tactile.beebrilliant.androidx-startup">

            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup" />
        </provider>

@shefich
Copy link
Author

shefich commented Dec 2, 2022

@Martin-Gonzalez90 it doesn't fix the issue.

@toseefhaiderkhansugguu
Copy link

try to initialize One Signal after all of your app Start methods you will see some improvements, I haven't seen any crashes today but still not satisfied its not a solution :/

@jkasten2
Copy link
Member

jkasten2 commented Dec 3, 2022

@toseefhaiderkhansugguu Thanks for letting us know you can sometimes reproduce the issue, this is key since we haven't seen anyone reproduce the issue themselves (only seen end-user crash reports).

Could you share your FULL logcat (with VERBOSE logging).
We are mostly concerned about what happens just before this line, and all the way to the crash (including the crash itself)

Initializing WorkManager with default configuration.

If you don't see this line, that is ok, please still post the full logcat. Please also feel free to reach out to OneSignal support team referencing this issue and including your full logcat.

@toseefhaiderkhansugguu
Copy link

Logcat results you mean unity android logcat results? I dont know how to use android studio i can only share unity android logcat result

@jkasten2
Copy link
Member

jkasten2 commented Dec 3, 2022

@toseefhaiderkhansugguu There are a few ways to get the full logcat.

  1. Unity's Android Logcat Package
    • If you run into issues with it not finding devices you may have to restart Unity, or your system (or kill the adb background process)
  2. From the terminal with adb logcat
    • You can pipe this to a file by running adb logcat > myadbcat.txt, it logs forever so stop it (with Control+C) once you run into the issue.
  3. With Android Studio
    • Can can still build and run your app like normal with Unity, you can simply use Android Studio to view the logcat.

@toseefhaiderkhansugguu
Copy link

@toseefhaiderkhansugguu There are a few ways to get the full logcat.

  1. Unity's Android Logcat Package

    • If you run into issues with it not finding devices you may have to restart Unity, or your system (or kill the adb background process)
  2. From the terminal with adb logcat

    • You can pipe this to a file by running adb logcat > myadbcat.txt, it logs forever so stop it (with Control+C) once you run into the issue.
  3. With Android Studio

    • Can can still build and run your app like normal with Unity, you can simply use Android Studio to view the logcat.

Can you please provide your email ? i manged to reproduce this crash i want to share logical results

@nan-li
Copy link

nan-li commented Dec 5, 2022

Hi @toseefhaiderkhansugguu, thanks so much.

You can email [email protected] and reference this issue.

@toseefhaiderkhansugguu
Copy link

[email protected]

Check Email

@jkasten2
Copy link
Member

jkasten2 commented Dec 5, 2022

@toseefhaiderkhansugguu Thanks for the logs! I do not see "Initializing WorkManager with default configuration." or any other WorkManager before the "WorkManager is not initialized properly" crash. I see other debug log entries so I think you captured everything correctly.

Can you let us know the following details?

  1. Does the same build of this app work on other devices without any issues?
  2. Which devices get this crash that you have tested?
    • Just the :Oppo A12 Android version 9 you noted before?
  3. Can you share these files from your Unity build as well?
  • Temp\gradleOut\launcher\build\intermediates\merged_manifests\release\AndroidManifest.xml
  • Temp\gradleOut\launcher\build\intermediates\manifest_merge_blame_file\release\manifest-merger-blame-release-report.txt
  1. Could you share your APK?
  • APK is probably too large for an email. So you will need to share a link to it instead.

@toseefhaiderkhansugguu
Copy link

@toseefhaiderkhansugguu Thanks for the logs! I do not see "Initializing WorkManager with default configuration." or any other WorkManager before the "WorkManager is not initialized properly" crash. I see other debug log entries so I think you captured everything correctly.

Can you let us know the following details?

  1. Yes i haven't seen any crash on high end devices we mostly test app on low end devices
  2. Oppo A12 Android version 9 and HUAWEI y7 Prime with android 8.1.0
  1. Sent on email
  1. Could you share your APK?
  • APK is probably too large for an email. So you will need to share a link to it instead.

@jkasten2
Copy link
Member

jkasten2 commented Dec 5, 2022

Thanks for the logs, I see the built AndroidManifest.xml contains the correct entries for the WorkManger to start:

       <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="com.package.example.androidx-startup"
            android:exported="false" >
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup" />
            <meta-data
                android:name="androidx.lifecycle.ProcessLifecycleInitializer"
                android:value="androidx.startup" />
        </provider>

(if this was missing it would have an issue on all devices).

We don't have these specific tests to test with. I suspect the issue might be specific to a range of models. Would it be possible to also provide:

  1. A full verbose logcat with ALL message, including system ones (don't filter by your app)
  • If possible share this logcat from both your issue devices.
  • Wondering if we see some kind of Oppo or HUAWEI specific message showing androidx-startup was skipped for a reason.
  1. Does HUAWEI y7 Prime only crash in the same scenarios as your Oppo A12? Only after installing over the top of the development build and production build a few times?

@toseefhaiderkhansugguu
Copy link

Thanks for the logs, I see the built AndroidManifest.xml contains the correct entries for the WorkManger to start:

       <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="com.package.example.androidx-startup"
            android:exported="false" >
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup" />
            <meta-data
                android:name="androidx.lifecycle.ProcessLifecycleInitializer"
                android:value="androidx.startup" />
        </provider>

(if this was missing it would have an issue on all devices).

We don't have these specific tests to test with. I suspect the issue might be specific to a range of models. Would it be possible to also provide:

  1. Right now i have produced the crash on oppo so i am sharing full log on email

I will try to produce this on HUAWEI now
Yes both crashes are on app start at the time of initlization

@toseefhaiderkhansugguu
Copy link

@jkasten2 Tested same scenario on HUAWEI for hours and I am not able to re produce crash on it I don't know what is happening.. what should we do next ?

@jkasten2
Copy link
Member

jkasten2 commented Dec 5, 2022

@toseefhaiderkhansugguu I took a look but didn't see anything (even Oppo specific log entries) that would relate to providers or workmanger. It is still unknown why we are not seeing "Initializing WorkManager with default configuration." in your logs.

Possibly related errors

I do however see some other errors like this on your app startup they could be causing an issue.

Rejecting re-init on previously-failed class java.lang.Class<di2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/PacProcessor;
...
at void com.google.android.gms.ads.internal.webview.ac.<init>(com.google.android.gms.ads.internal.webview.aw,

Also:

Rejecting re-init on previously-failed class java.lang.Class<com.google.android.finsky.cloudsearch.PlayCloudSearchService>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/service/cloudsearch/CloudSearchService

Next Steps

@toseefhaiderkhansugguu
Looks like these errors are coming from a Google Ads and CloudSearchService plugins. Can you try resolving it to see if it helps? You could temporary remove it if you can't find how to fix this specific error, just to see if these errors are the cause.

@toseefhaiderkhansugguu
Copy link

@toseefhaiderkhansugguu I took a look but didn't see anything (even Oppo specific log entries) that would relate to providers or workmanger. It is still unknown why we are not seeing "Initializing WorkManager with default configuration." in your logs.

Possibly related errors

I do however see some other errors like this on your app startup they could be causing an issue.

Rejecting re-init on previously-failed class java.lang.Class<di2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/PacProcessor;
...
at void com.google.android.gms.ads.internal.webview.ac.<init>(com.google.android.gms.ads.internal.webview.aw,

Also:

Rejecting re-init on previously-failed class java.lang.Class<com.google.android.finsky.cloudsearch.PlayCloudSearchService>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/service/cloudsearch/CloudSearchService

Next Steps

@toseefhaiderkhansugguu Looks like these errors are coming from a Google Ads and CloudSearchService plugins. Can you try resolving it to see if it helps? You could temporary remove it if you can't find how to fix this specific error, just to see if these errors are the cause.

@jkasten2 can you please tell me Firebase Messaging package is necessary for One-signal push notification?

@jkasten2
Copy link
Member

jkasten2 commented Dec 6, 2022

@toseefhaiderkhansugguu OneSignal does not need the Unity Firebase Messaging package. You can remove it if you don't need it.

  • Internally OneSignal-Android-SDK used by this SDK depends on the native Java firebase-messaging under the hood, but that isn't exposed to Unity.

@Mustafax06
Copy link

Mustafax06 commented Mar 14, 2024

Has anyone fixed this issue or have any updates from the devs?

@jkasten2
Copy link
Member

jkasten2 commented Mar 14, 2024

@Mustafax06 we added a speculative workaround to the "WorkManager is not initialized" issue in OneSignal-Unity-SDK 3.0.10.

We haven't see any new reports of "not initialized" errors since then, however different but similar error "already initialized" has come up since then.

Have you updated to OneSignal-Unity-SDK 3.0.10 or newer and still seeing this issue?

@nan-li
Copy link

nan-li commented Jun 20, 2024

Hi all, we made updates to Work Manager in Release 5.1.15 for the User Model SDK and Release 4.8.10 for the Player Model SDK.

@shefich
Copy link
Author

shefich commented Jun 20, 2024

Hi all, we made updates to Work Manager in Release 5.1.15 for the User Model SDK and Release 4.8.10 for the Player Model SDK.

Need update for version 3.x.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants