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

PlatformException when calling OneSignal.setAppId on Android #494

Closed
HarkerTech opened this issue Oct 12, 2021 · 11 comments
Closed

PlatformException when calling OneSignal.setAppId on Android #494

HarkerTech opened this issue Oct 12, 2021 · 11 comments

Comments

@HarkerTech
Copy link

Description:

Seeing platform exceptions reported through Sentry when setting the app id during app start up on Android.

Seen on Android 9,10, and 11.

Environment
onesignal_flutter: ^3.2.3
Flutter 2.5.1

Steps to Reproduce Issue:

Unfortunately have not been able to replicate this locally yet.

Anything else:

Exception details

PlatformException: PlatformException(error, Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference at com.onesignal.r1.d(OSObservable.java:3) at com.onesignal.v2.O1(OneSignal.java:3) at com.onesignal.flutter.OneSignalPlugin.r(OneSignalPlugin.java:1) at com.onesignal.flutter.OneSignalPlugin.K(OneSignalPlugin.java:7) at com.onesignal.flutter.OneSignalPlugin.onMethodCall(OneSignalPlugin.java:2) at e.a.c.a.j$a.a(MethodChannel.java:2) at io.flutter.embedding.engine.f.b.e(DartMessenger.java:4) at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:2) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:335) at android.os.Looper.loop(Looper.java:206) at android.app.ActivityThread.main(ActivityThread.java:8595) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) ) File "message_codecs.dart", line 607, in StandardMethodCodec.decodeEnvelope File "platform_channel.dart", line 156, in MethodChannel._invokeMethod File "<asynchronous suspension>" File "onesignal_flutter.dart", line 63, in OneSignal.setAppId File "<asynchronous suspension>" File "notificationHelper.dart", line 29, in NotificationHelper.init File "<asynchronous suspension>" File "app.dart", line 38, in _MyAppState.initPlatformState

Have taken a look through the code to try identify the issue. It is possibly related to the changes in #445. In the Android SDK (if I have interpreted correctly) it appears that the "removeObserver" function does not account for if a weak reference has been cleared so possibly this is the root cause? https://github.com/OneSignal/OneSignal-Android-SDK/blob/main/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSObservable.java#L58. Will downgrade to 3.1.0 to try and confirm this is the case.

@mas7
Copy link

mas7 commented Oct 17, 2021

I have the same problem, any solution ?

@mas7
Copy link

mas7 commented Oct 17, 2021

I noticed that the issue happens when clicking on home button and the app in the background, then getting back to the app again

@thiagomarcelop
Copy link

I have the same problem.

@aayush0208
Copy link

Getting same error after trying this solution

@HarkerTech
Copy link
Author

After downgrading to 3.1.0 we are no longer seeing this issue reported.

@macortesn
Copy link

I have the same issue

@jkasten2
Copy link
Member

Thanks for reporting, we will investigate the removeObserver on the OneSignal-Android-SDK and the PR #445 as it seems they are related to this issue.

@rodolfosaraiva
Copy link

same issue

1 similar comment
@muja555
Copy link

muja555 commented Jan 2, 2022

same issue

@jkasten2
Copy link
Member

Quick update for those following this issue. There is a pull request which fixes an underlining issue with the native OneSignal-Android-SDK this OneSignal-Flutter-SDK depends on. The issue was reproduced consistently via a unit test, a fix was implemented, and the test was re-run to confirm the fix. We will be prioritizing a release to get this fix rolled out quickly.

@jkasten2
Copy link
Member

This is now fixed and is part of the OneSignal-Flutter-SDK 3.2.8 Release.

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

8 participants