Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19437] Android: Null passed to putExtra() causes app to crash

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-08-31T18:43:27.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.0.0
ComponentsAndroid
Labelsn/a
ReporterTim Poulsen
AssigneeHieu Pham
Created2015-08-18T15:17:01.000+0000
Updated2017-03-22T22:41:32.000+0000

Description

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.
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): 	at org.appcelerator.titanium.proxy.IntentProxy.putExtra(IntentProxy.java:198)
06-30 14:06:51.234: W/System.err(19120): 	at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
06-30 14:06:51.234: W/System.err(19120): 	at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177)
06-30 14:06:51.234: W/System.err(19120): 	at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299)
06-30 14:06:51.234: W/System.err(19120): 	at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203)
06-30 14:06:51.234: W/System.err(19120): 	at android.os.Handler.dispatchMessage(Handler.java:98)
06-30 14:06:51.234: W/System.err(19120): 	at android.os.Looper.loop(Looper.java:145)
06-30 14:06:51.234: W/System.err(19120): 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
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.
@Kroll.method
public void putExtra(String key, Object value)
{
	if (value == null) {
		return;
	}
...
https://github.com/appcelerator/titanium_mobile/pull/6958 (master) https://github.com/appcelerator/titanium_mobile/pull/6957 (3_5_X)

Comments

  1. Lee Morris 2017-03-22

    Closing ticket as fixed.

JSON Source