Project: titanium
Issue TIMOB-19437: Android: Null passed to putExtra() causes app to crash
Creating a separate ticket for my comments on TIMOB-18098. PR https://github.com/appcelerator/titanium_mobile/pull/6958 Our app crashes frequently when the it's woken from the background by the user tapping a push notification. We are using the http://iamyellow.net/post/40100981563/gcm-appcelerator-titanium-module GCM module. {code} 06-30 14:06:51.234: W/System.err(19120): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference 06-30 14:06:51.234: W/System.err(19120): org.appcelerator.titanium.proxy.IntentProxy.putExtra(IntentProxy.java:198) 06-30 14:06:51.234: W/System.err(19120): org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) 06-30 14:06:51.234: W/System.err(19120): org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177) 06-30 14:06:51.234: W/System.err(19120): org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299) 06-30 14:06:51.234: W/System.err(19120): org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203) 06-30 14:06:51.234: W/System.err(19120): android.os.Handler.dispatchMessage(Handler.java:98) 06-30 14:06:51.234: W/System.err(19120): android.os.Looper.loop(Looper.java:145) 06-30 14:06:51.234: W/System.err(19120): org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) {code} If the app is open when the message arrives, it is received and handled fine. If the app is in the background, we see the above in the adb logs. I have tried with 3.5.0.GA, 3.5.1.GA, 4.0.0.GA, and a nightly I built myself (don't recall the date of that build, but post GA). Tested on both Android 5.0 and 4.2.2 devices. I have found that a simple null value check in the putExtra() method resolves this issue. {code} @Kroll.method public void putExtra(String key, Object value) {	if (value == null) {	return;	} ... {code} https://github.com/appcelerator/titanium_mobile/pull/6958 (master) https://github.com/appcelerator/titanium_mobile/pull/6957 (3_5_X)
Story points: 3