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]: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference #535

Open
1 task done
RaphaelNSG opened this issue Sep 15, 2022 · 1 comment

Comments

@RaphaelNSG
Copy link

RaphaelNSG commented Sep 15, 2022

What happened?

I'm receiving this log in the game initialization on Android devices:

Error WM-WorkerWrapper Work [ id=8ce410e8-2b8c-4053-9f84-203912c55765, tags={ FOCUS_LOST_WORKER_TAG, com.onesignal.OSFocusHandler$OnLostFocusWorker } ] failed because it threw an exception/error
Error WM-WorkerWrapper java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
Error WM-WorkerWrapper 	at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
Error WM-WorkerWrapper 	at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
Error WM-WorkerWrapper 	at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)
Error WM-WorkerWrapper 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
Error WM-WorkerWrapper 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
Error WM-WorkerWrapper 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
Error WM-WorkerWrapper 	at java.lang.Thread.run(Thread.java:1012)
Error WM-WorkerWrapper Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
Error WM-WorkerWrapper 	at com.onesignal.OSUtils.packageInstalledAndEnabled(OSUtils.java:275)
Error WM-WorkerWrapper 	at com.onesignal.OSUtils.isGMSInstalledAndEnabled(OSUtils.java:288)
Error WM-WorkerWrapper 	at com.onesignal.OSUtils.supportsGooglePush(OSUtils.java:330)
Error WM-WorkerWrapper 	at com.onesignal.OSUtils.getDeviceType(OSUtils.java:349)
Error WM-WorkerWrapper 	at com.onesignal.OSUtils.isAndroidDeviceType(OSUtils.java:371)
Error WM-WorkerWrapper 	at com.onesignal.LocationController.isGooglePlayServicesAvailable(LocationController.java:337)
Error WM-WorkerWrapper 	at com.onesignal.LocationController.onFocusChange(LocationController.java:325)
Error WM-WorkerWrapper 	at com.onesignal.OneSignal.onAppLostFocus(OneSignal.java:1352)
Error WM-WorkerWrapper 	at com.onesignal.OSFocusHandler$Companion.onLostFocusDoWork(OSFocusHandler.kt:139)
Error WM-WorkerWrapper 	at com.onesignal.OSFocusHandler$OnLostFocusWorker.doWork(OSFocusHandler.kt:118)
Error WM-WorkerWrapper 	at androidx.work.Worker$1.run(Worker.java:86)
Error WM-WorkerWrapper 	... 3 more

Steps to reproduce?

1. Install OneSignal 3.0.3
2. Initialize game on Android
3. Check logcat

What did you expect to happen?

I expected not to see this log.

Unity version

2019.4.35f1

OneSignal Unity SDK version

3.0.3

Platform

Android

Relevant log output

09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper Work [ id=8ce410e8-2b8c-4053-9f84-203912c55765, tags={ FOCUS_LOST_WORKER_TAG, com.onesignal.OSFocusHandler$OnLostFocusWorker } ] failed because it threw an exception/error
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at java.lang.Thread.run(Thread.java:1012)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSUtils.packageInstalledAndEnabled(OSUtils.java:275)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSUtils.isGMSInstalledAndEnabled(OSUtils.java:288)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSUtils.supportsGooglePush(OSUtils.java:330)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSUtils.getDeviceType(OSUtils.java:349)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSUtils.isAndroidDeviceType(OSUtils.java:371)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.LocationController.isGooglePlayServicesAvailable(LocationController.java:337)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.LocationController.onFocusChange(LocationController.java:325)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OneSignal.onAppLostFocus(OneSignal.java:1352)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSFocusHandler$Companion.onLostFocusDoWork(OSFocusHandler.kt:139)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at com.onesignal.OSFocusHandler$OnLostFocusWorker.doWork(OSFocusHandler.kt:118)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	at androidx.work.Worker$1.run(Worker.java:86)
09/15 18:10:46.608 24601 24706 Error WM-WorkerWrapper 	... 3 more

Code of Conduct

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

shefich commented Mar 14, 2024

Same for me.
OneSignal Unity SDK version 3.0.11
Unity 2020, 2021, 2022.

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

2 participants