-
Notifications
You must be signed in to change notification settings - Fork 61
Description
What happened?
I get a null exception, using Unity 6 latest release but it happens in every single Unity 6 version as far as I know.
I put this guided from your examples on the tutorials, inside a Start method
OneSignal.Debug.LogLevel = LogLevel.Verbose;
OneSignal.Debug.AlertLevel = LogLevel.Fatal;
OneSignal.ConsentRequired = false;
OneSignal.Notifications.Clicked += _notificationOnClick;
OneSignal.Notifications.ForegroundWillDisplay += _notificationOnDisplay;
OneSignal.Notifications.PermissionChanged += _notificationPermissionChanged;
OneSignal.User.PushSubscription.Changed += _pushSubscriptionChanged;
OneSignal.User.Changed += _userStateChanged;
// OneSignal Initialization
// OneSignal.Default.Initialize("xxxxx"); <-- I've also tried this, but you will get a null pointer exception when you run it on the device
OneSignal.Initialize("xxxx"); <-- You will get a null pointer exception when you run it on the device
It looks it does not find the OneSignal.Default class or whatever it is, throwing a null exception. On previous versions of the plugin it worked fine.
The device logcat:
04-06 12:48:59.417 25651 25673 I Unity : Error initing pushmanager:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.onesignal.OneSignal
04-06 12:48:59.417 25651 25673 I Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
04-06 12:48:59.417 25651 25673 I Unity : at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0
04-06 12:48:59.417 25651 25673 I Unity : at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <00000000000000000000000000000000>:0
04-06 12:48:59.417 25651 25673 I Unity : at OneSignalSDK.Android.OneSignalAndroid..ctor () [0x00000] in ./Library/PackageCache/com.onesignal.unity.android@b7bd870878d9/Runtime/OneSignalAndroid.cs:53
04-06 12:48:59.417 25651 25673 I Unity : at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00000] in <00000000000000000000000000000000>:0
04-06 12:48:59.417 25651 25673 I Unity : at OneSignalSDK.OneSignal._getDefaultInstance () [0x00000] in ./Library/PackageCache/com.onesignal.
Steps to reproduce?
Unity 6, build and run on android device.
What did you expect to happen?
It should not throw a null exception
Unity version
Unity 6 (latest)
OneSignal Unity SDK version
latest
Platform
Android
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct