urbanairship / android-library

Urban Airship Android SDK
Other
112 stars 123 forks source link

NullPointerException in ActionButtonGroupsParser.fromXml() #27

Closed korre closed 7 years ago

korre commented 7 years ago

I'm seeing some crashes on different devices in crashlytics. It happens on different Android versions as well, ranging from Android 5 to 7.

We're running Urban Airship version: 8.6.1

As far as I can see you've wrapped the code in fromXml in a try/catch but is not catching this particular error. Any ideas how we should handle this? It's on our top 3 crashes at the moment.

The stacktrace looks like this:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference at android.content.res.AssetManager.getResourceValue(AssetManager.java:201) at android.content.res.Resources.getValue(Resources.java:1397) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2882) at android.content.res.Resources.getXml(Resources.java:1264) at com.urbanairship.push.ActionButtonGroupsParser.fromXml(ActionButtonGroupsParser.java:49) at com.urbanairship.push.PushManager.(PushManager.java) at com.urbanairship.push.PushManager.(PushManager.java) at com.urbanairship.UAirship.init(UAirship.java:582) at com.urbanairship.UAirship.executeTakeOff(UAirship.java:365) at com.urbanairship.UAirship.access$000(UAirship.java:45) at com.urbanairship.UAirship$2.run(UAirship.java:325) at java.lang.Thread.run(Thread.java:818)

marc-scig commented 7 years ago

Hi there,

Could you provide a link to the crash? This might help us try to figure out any common themes, such as devices or OS versions. Worst case scenario we can catch the NPE, though of course it would be better to understand exactly what's causing it. The actual exception is rather deep into framework code.

korre commented 7 years ago

Oh. I wasn't aware of the awesome feature of sharing crashes in fabric @marc-scig so here it is:

http://crashes.to/s/3a95860716f

marc-scig commented 7 years ago

Thanks! One more thing that might help would be your build.gradle file (just in case something funny is happening with the resources). In any event we should be releasing a patch tomorrow that should hedge against this in the catch block. We'll let you know when it's out.

korre commented 7 years ago

Sounds good @marc-scig. Awaiting your patch. There seems to be a similar problem in your ActionRegistry. Can be seen here: http://crashes.to/s/7143e46b60d

rlepinski commented 7 years ago

@korre How are you calling takeoff ? Autopilot?

korre commented 7 years ago

@rlepinski Called from our Application.onCreate() on app start. What do you mean by Autopilot?

    UAirship.takeOff(this, uaOptions, new UAirship.OnReadyCallback() {
        @Override
        public void onAirshipReady(UAirship airship) {
            airship.getPushManager().setChannelTagRegistrationEnabled(false);
            airship.getPushManager().setNotificationFactory(notificationBuilder);
            airship.getPushManager().setPushEnabled(true);
            airship.getPushManager().setUserNotificationsEnabled(true);

            if (BuildConfig.DEBUG) {
                Lo.i(TAG, "Device Id: " + NotificationApi.getDeviceToken());
            }

            Action customAction = new PurgeCacheAction();
            UAirship.shared()
                    .getActionRegistry()
                    .registerAction(customAction, UA_OPTION_PURGE_CACHE);
        }
    });
rlepinski commented 7 years ago

We released 8.9.2 with a fix for both xml parsing methods. Thanks for the info.