saravanarajan / acra

Automatically exported from code.google.com/p/acra
0 stars 0 forks source link

NullPointerException when building crash report because getDeviceId() returns null #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Install on any device that does not support TelephonyManager.getDeviceId()
2. Try and send crash logs using 
ErrorReporter.getInstance().handleException(null);

What is the expected output? What do you see instead?

Should deal with the problem more gracefully

What version of the product are you using? On what operating system?

I'm running ACRA 4.2.3 on a modified version of Android 2.2 on a generic tablet 
device

Please provide any additional information below.

PROPOSED CHANGE: ErrorReporter class lines 455 to 459 should be changed from...

                    String deviceId = tm.getDeviceId();
                    if (deviceId != null) {
                        mCrashProperties.put(DEVICE_ID, deviceId);
                    }

...to...

                    if(tm != null) {
                        String deviceId = tm.getDeviceId();
                        if (deviceId != null) {
                            mCrashProperties.put(DEVICE_ID, deviceId);
                        }
                    }

Original issue reported on code.google.com by rupert.r...@gmail.com on 3 Dec 2011 at 4:29

GoogleCodeExporter commented 9 years ago
UPDATE: This doesn't cause a crash in the trunk version, which has an exception 
wrapper around this section of code. However, I would still recommend adding 
the null test to avoid a spurious NullPointerException. The code location is 
now in ReportUtils.java line 61.

Original comment by rupert.r...@gmail.com on 4 Dec 2011 at 9:27

GoogleCodeExporter commented 9 years ago
Beware, the trunk version is highly unstable (app hanging after crashing) 
because I'm rewriting the app process management and how its final death is 
triggered.

Your report is important, I had not thought that the TelephonyManager was null 
on devices without telephony.

Thanks for reporting.

Original comment by kevin.gaudin on 4 Dec 2011 at 5:34

GoogleCodeExporter commented 9 years ago
Thanks for the heads-up about the trunk. I was only poking around to see where 
it ways; I'll keep using the release version and just disable the device ID 
option.

Original comment by rupert.r...@gmail.com on 4 Dec 2011 at 6:57

GoogleCodeExporter commented 9 years ago
If you ever need it, there is a more recent version, still in a beta state but 
definitely more stable than the trunk:
http://code.google.com/p/acra/source/browse/repository/snapshots/org/acra/acra/4
.3.0-SNAPSHOT/acra-4.3.0-20111103.232318-3.jar

Original comment by kevin.gaudin on 4 Dec 2011 at 7:28

GoogleCodeExporter commented 9 years ago
does this snapshot handle this NPE ?

Original comment by pujos.mi...@gmail.com on 19 Dec 2011 at 1:25

GoogleCodeExporter commented 9 years ago
Well, yes, it should be fixed in this snapshot.
I just looked at it and William Ferguson already had fixed it while doing his 
ACRA code review/cleaning after the 4.2.3 publication.

Kevin

Original comment by kevin.gaudin on 19 Dec 2011 at 9:48

GoogleCodeExporter commented 9 years ago

Original comment by kevin.gaudin on 7 Sep 2012 at 9:37