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]: OneSignalService.onPostAppCreated java.lang.NullPointerException #1917

Closed
1 task done
albertoderodrigo opened this issue Nov 20, 2023 · 13 comments
Closed
1 task done

Comments

@albertoderodrigo
Copy link

albertoderodrigo commented Nov 20, 2023

What happened?

Since que upgraded from OneSignal 4.X.X to OneSignal 5.0.4 we started to see the following error on Firebase crashlytics.

Caused by java.lang.NullPointerException:
at com.onesignal.core.internal.application.impl.ApplicationService.getAppContext(ApplicationService.kt:39)
at com.onesignal.core.internal.preferences.impl.PreferencesService.getSharedPrefsByName(PreferencesService.kt:234)
at com.onesignal.core.internal.preferences.impl.PreferencesService.get(PreferencesService.kt:134)
at com.onesignal.core.internal.preferences.impl.PreferencesService.getString(PreferencesService.kt:42)
at com.onesignal.common.modeling.ModelStore.load(ModelStore.kt:165)
at com.onesignal.common.modeling.SimpleModelStore.(SimpleModelStore.kt:23)
at com.onesignal.core.internal.config.ConfigModelStore.(ConfigModelStore.kt:8)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:89)
at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79)
at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67)
at com.onesignal.common.services.ServiceProvider.getService$com_onesignal_core(ServiceProvider.kt:39)
at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:188)
at com.onesignal.OneSignal.initWithContext(OneSignal.kt:135)

Full Log

This happens on the start up and in a variety of devices and Android Versions.

Screenshot 2023-11-20 at 09 05 09

Steps to reproduce?

Upgrade to OneSignal 5.0.4 aande wait for the errors on Firebase crashlytics.

We didn't find a way to reproduce it in our test devices.

What did you expect to happen?

No errors on FIrebase crashlytics

OneSignal Android SDK version

5.0.4

Android version

13, 12, 11, 10, 9

Specific Android models

No response

Relevant log output

No response

Code of Conduct

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

Thank you for reaching out! We'll investigate this.

@albertoderodrigo
Copy link
Author

Hi we just updated to the latest of the sdk 5.0.5 and the problem remains.

Screenshot 2023-12-14 at 09 36 28

this is a fresh log

io.socialgamesonline.slotcom_issue_b195941da1928b51d7cb0e43076dd8dc_crash_session_657A7843002D00017F30B9EF82B82DED_DNE_0_v2_stacktrace (1).txt

@albertoderodrigo
Copy link
Author

Hello just for your info we just updated to the latest versión 5.1.0 and the error remains.

io.socialgamesonline.slotcom_issue_b195941da1928b51d7cb0e43076dd8dc_crash_session_6595FBD7003100011A74FA3E34186E71_DNE_0_v2_stacktrace.txt

This is the top error in our app :(

Screenshot 2024-01-04 at 08 35 38

@albertoderodrigo
Copy link
Author

Hello we released a new version with the 5.1.1 and the error persists (But we reduced ARN thx!).

This is a log with the last version

io.socialgamesonline.slotcom_issue_b195941da1928b51d7cb0e43076dd8dc_crash_session_65B0A5B7008E00012846EADB61154D90_DNE_0_v2_stacktrace.txt

Can you give me some feedback @jennantilla please is the most frequent error on our app.

Regards

@albertoderodrigo
Copy link
Author

Hello? any news regarding this @jennantilla.

@nan-li
Copy link
Contributor

nan-li commented Feb 2, 2024

Hi @albertoderodrigo, Thank you for following up with your updates and attaching new stacktraces.

I am noting for ourselves to investigate that the stacktraces show two scenarios that triggered the getAppContext NPE:

com.onesignal.core.internal.preferences.impl.PreferencesService.getSharedPrefsByName(PreferencesService.kt:234)
com.onesignal.core.internal.device.impl.DeviceService.packageInstalledAndEnabled(DeviceService.kt:106)

We have no updates yet.

@albertoderodrigo
Copy link
Author

Hi @nan-li,

We can add more logs or traces at the moment that the exception is raised. What information could help you?

@nan-li
Copy link
Contributor

nan-li commented Feb 20, 2024

Hi @albertoderodrigo,

I have looked at your logs again, and they all arise from your app's method onPostAppCreated calling OneSignal.initWithContext. Can you share what kind of context you are passing?

       at com.onesignal.OneSignal.initWithContext(OneSignal.kt:135)
       at io.socialgamesonline.slotcom.features.OneSignalService.onPostAppCreated(OneSignalService.kt:38)

Also, do you see any crashes that originate from other sources that are not from you calilng the method, such as BroadcastReceivers, etc?

@albertoderodrigo
Copy link
Author

Hi @nan-li.

We use the getApplicationContext from the custom Application. This is provided on the onCreate event.

Screenshot 2024-02-23 at 14 55 23

I just checked a lot of this crashes an all are originated from the same source. Has your initWithContext checks if context is null then the only possibility that i see is that sometimes ApplicationService init has not been called before the trying to acquire the context from it.

@jkasten2
Copy link
Member

jkasten2 commented Mar 2, 2024

We have a fix that will lower and possibly fix all crashes related to this null Context being thrown from initWithContext issue in the OneSignal-Android-SDK 5.1.6 release.

@albertoderodrigo if you continue to seeing this issue after updating to 5.1.6 please let us know the new percentages of crashes the new stack traces.

@albertoderodrigo
Copy link
Author

Hi @jkasten2, we just releases a hotfix with your update. On Monday I will let you know if it has disappeared or not.

Thx

@albertoderodrigo
Copy link
Author

Hi @jkasten2, the error disappeared!! Thx!

@jkasten2
Copy link
Member

jkasten2 commented Mar 4, 2024

@albertoderodrigo That is awesome to hear! Appreciate you reporting back the results!

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

4 participants