OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
606 stars 371 forks source link

[Bug]: OneSignal.initWithContext() crashes on (5.0.0) #1812

Closed SonicOctavesSuyash closed 11 months ago

SonicOctavesSuyash commented 1 year ago
suyashraikar commented 1 year ago
       Process: com.simpletherapy.android.mhealth, PID: 18149
                                                                                                java.lang.RuntimeException: Unable to create application com.simpletherapy.android.SimpleTherapyApplication: java.lang.NullPointerException: null cannot be cast to non-null type com.amazon.device.iap.PurchasingListener
                                                                                                    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6955)
                                                                                                    at android.app.ActivityThread.access$1300(ActivityThread.java:260)
                                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1972)
                                                                                                    at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    at android.os.Looper.loop(Looper.java:223)
                                                                                                    at android.app.ActivityThread.main(ActivityThread.java:7989)
                                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:635)
                                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1065)
                                                                                                Caused by: java.lang.NullPointerException: null cannot be cast to non-null type com.amazon.device.iap.PurchasingListener
                                                                                                    at com.onesignal.core.internal.purchases.impl.TrackAmazonPurchase.start(TrackAmazonPurchase.kt:83)
                                                                                                    at com.onesignal.core.internal.startup.StartupService.start(StartupService.kt:16)
                                                                                                    at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:247)
                                                                                                    at com.onesignal.OneSignal.initWithContext(OneSignal.kt:126)
                                                                                                    at com.simpletherapy.android.SimpleTherapyApplication.onCreate(SimpleTherapyApplication.java:187)
                                                                                                    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
                                                                                                    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6949)
                                                                                                    at android.app.ActivityThread.access$1300(ActivityThread.java:260) 
                                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1972) 
                                                                                                    at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                    at android.os.Looper.loop(Looper.java:223) 
                                                                                                    at android.app.ActivityThread.main(ActivityThread.java:7989) 
                                                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:635) 
                                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1065) 
khurramaleee commented 1 year ago

Did you find any solution?

suyashraikar commented 1 year ago

Still not any solution @khurramaleee

michael-winkler commented 1 year ago

@emawby Can you please take a look here too?

emawby commented 1 year ago

@michael-winkler Yep we are trying to reproduce this one as well is this only happening on Amazon fire devices?

suyashraikar commented 1 year ago

@michael-winkler No this is happening on all devices.

bordot commented 1 year ago

Having the same issue.

Exception java.lang.RuntimeException:

 at android.app.ActivityThread.callActivityOnStop (ActivityThread.java:5843)
  at android.app.ActivityThread.performStopActivityInner (ActivityThread.java:5809)
  at android.app.ActivityThread.handleStopActivity (ActivityThread.java:5880)
  at android.app.servertransaction.StopActivityItem.execute (StopActivityItem.java:43)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2574)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8762)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
Caused by java.lang.NullPointerException: null cannot be cast to non-null type com.amazon.device.iap.PurchasingListener
  at com.onesignal.core.internal.purchases.impl.TrackAmazonPurchase.onUnfocused (TrackAmazonPurchase.kt:124)
  at com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke (ApplicationService.kt:325)
  at com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke (ApplicationService.kt:325)
  at com.onesignal.common.events.EventProducer.fire (EventProducer.kt:44)
  at com.onesignal.core.internal.application.impl.ApplicationService.handleLostFocus (ApplicationService.kt:325)
  at com.onesignal.core.internal.application.impl.ApplicationService.onActivityStopped (ApplicationService.kt:184)
  at android.app.Application.dispatchActivityStopped (Application.java:510)
  at android.app.Activity.dispatchActivityStopped (Activity.java:1548)
  at android.app.Activity.onStop (Activity.java:2679)
  at androidx.fragment.app.FragmentActivity.onStop (FragmentActivity.java:496)
  at androidx.appcompat.app.AppCompatActivity.onStop (AppCompatActivity.java:252)
  at android.app.Instrumentation.callActivityOnStop (Instrumentation.java:1551)
  at android.app.Activity.performStop (Activity.java:8829)
  at android.app.ActivityThread.callActivityOnStop (ActivityThread.java:5835)

The crashes seem to have been from Android users that installed from Play Store, not Amazon store. Samsung devices, not Amazon devices also.

brismithers commented 1 year ago

@suyashraikar could you post which version of com.amazon.device:amazon-appstore-sdk you're including as a dependency for your app?

suyashraikar commented 1 year ago

@brismithers we don't include any "com.amazon.device:amazon-appstore-sdk" any specific dependency in app. I guess this is internally used by OneSignal . @brismithers we can connect to get more clear.

brismithers commented 1 year ago

Good news, I was able to reproduce the issue with com.amazon.device:amazon-appstore-sdk:3.0.3, the crash happens if an unfocus happens early during initialization, I believe we need to add a little bit more to the fix we provided in #1860. Will get that fix out shortly!

@suyashraikar I don't believe this issue can happen unless your app (either explicitly or through a dependency of yours) loads in this library, the OneSignal SDK depends on it as compileOnly and has a runtime check to ensure this code only runs when the library is loaded. To be sure I've covered everything, can you run ./gradlew app:dependencies and let me know the version of com.amazon.device:amazon-appstore-sdk?

jennantilla commented 11 months ago

Hello everyone! Just a heads up that this should be resolved in SDK versions >=5.0.4. Please feel free to update to the latest version and let us know if there are any additional questions or concerns!