onesignal-expo-plugin icon indicating copy to clipboard operation
onesignal-expo-plugin copied to clipboard

Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object referenceBug]:

Open metadevj opened this issue 1 year ago • 3 comments

What happened?

NPE while Google was doing their Pre Launch testing

Steps to reproduce?

NA

What did you expect to happen?

NA

OneSignal Expo SDK version

1.1.2

Platform

Android

Relevant log output

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
    at com.onesignal.PermissionsActivity.reregisterCallbackHandlers(PermissionsActivity.java:109)
    at com.onesignal.PermissionsActivity.handleBundleParams(PermissionsActivity.java:100)
    at com.onesignal.PermissionsActivity.onCreate(PermissionsActivity.java:82)
    at android.app.Activity.performCreate(Activity.java:7009)
    at android.app.Activity.performCreate(Activity.java:7000)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
    at android.app.ActivityThread.-wrap11
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.evtrack.connect.stationhouse/com.onesignal.PermissionsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
    at android.app.ActivityThread.-wrap11
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)




Permissions	
{
ACCESS_NETWORK_STATE: granted, 
ACCESS_WIFI_STATE: granted, 
BADGE_COUNT_READ: not_granted, 
BADGE_COUNT_WRITE: not_granted, 
BIND_GET_INSTALL_REFERRER_SERVICE: not_granted, 
BROADCAST_BADGE: not_granted, 
C2D_MESSAGE: granted, 
CHANGE_BADGE: not_granted, 
FOREGROUND_SERVICE: not_granted, 
INTERNET: granted, 
POST_NOTIFICATIONS: not_granted, 
PROVIDER_INSERT_BADGE: not_granted, 
READ: not_granted, 
READ_APP_BADGE: not_granted, 
READ_CONTACTS: not_granted, 
READ_EXTERNAL_STORAGE: not_granted, 
READ_SETTINGS: not_granted, 
RECEIVE: granted, 
RECEIVE_BOOT_COMPLETED: granted, 
SYSTEM_ALERT_WINDOW: not_granted, 
UPDATE_BADGE: not_granted, 
UPDATE_COUNT: not_granted, 
UPDATE_SHORTCUT: not_granted, 
VIBRATE: granted, 
WAKE_LOCK: granted, 
WRITE: not_granted, 
WRITE_CONTACTS: not_granted, 
WRITE_EXTERNAL_STORAGE: not_granted, 
WRITE_SETTINGS: not_granted
}
Device
Architectures	
[
x86
]
Battery Level	
100%
Boot Time	
2022-09-09T02:21:08.741Z(6 minutes before this event)
Brand	
google
Charging	
True
Connection Type	
wifi
Family	
Nexus
Free Memory	
1.3 GiB
Free Storage	
358.7 MiB
Id	
2ee60e8d-0d36-4eb5-8c87-afeae2459135
Language	
English
Low Memory	
False
Manufacturer	
LGE
Memory Size	
2.0 GiB
Model	
Nexus 5X (OSM1.180201.031)
Model Id	
OSM1.180201.031
Name	
Android SDK built for x86
Online	
True
Orientation	
portrait
Screen Density	
2.625
Screen DPI	
420
Screen Height Pixels	
1794
Screen Resolution	
1080x1794
Screen Width Pixels	
1080
Simulator	
False
Storage Size	
774.9 MiB
Timezone	
GMT
Battery Temperature	
25
Locale	
en_US
Operating System
Kernel Version	
3.18.91+
Name	
Android
Rooted	
no
Version	
8.1.0(OSM1.180201.031)
SDK
Name	
sentry.java.android
Version	
6.3.0

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

metadevj avatar Sep 09 '22 09:09 metadevj

Hi @metadevj , it looks like getExtras() can return null when no extras have been added. Looking at the OneSignal Android code it isn't apparent how this can happen.

Can you provide more information in terms of what the user/app was doing when this occurred? Specifically I'm wondering which permission was being requested.

Thanks!

brismithers avatar Sep 09 '22 18:09 brismithers

@brismithers I've submitted multiple more builds to Google for Pre Launch testing and I'm unable to replicate the issue. If it helps, see Sentry breadcrumbs:

ui.click
{
view.class: android.widget.ListView, 
view.id: list
}
Info
04:26:43
ui.lifecycle
{
screen: DevSettingsActivity, 
state: paused
}
Info
04:26:53
ui.lifecycle
{
screen: PermissionsActivity, 
state: created
}
Info
04:26:53
exception
NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
Error
04:26:53

metadevj avatar Sep 15 '22 12:09 metadevj

Thanks for the additional information and appreciate the update @metadevj. Unfortunately not able to reproduce this on my end. Here's some background info that might help a reproduction on your side, if you're able to reproduce it let me know the steps and we will take a look!

When your app calls promptForPushNotificationsWithUserResponse or promptLocation on the react side that translates to the Android native SDK calling PermissionsActivity.startPrompt. startPrompt sets up the PermissionsActivity adding extras to the intent before starting the activity. Android creates/shows the activity, our PermissionsActivity.onCreate will pull the extras that were set (this is where the NPE happens).

My initial thinking is to try backgrounding/foregrounding, clicking on other items in your dev settings view, etc.

brismithers avatar Sep 15 '22 14:09 brismithers