1

I have an application on google play. I made a new version with a higher versioncode and different name. Tested it on my own android device (v2.3.3) and an emulator (v4.0.3). No errors so far, so i put the update on the market.

Now the first error reports come in!!!!! (see below) I dont know what it means.

The new update was a little change in the permissions and i removed two libraries (jumptap SDK and jumptap adapter for admob mediation). The removed permissions were:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Leaving these two for admob ads:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

The error code:

 java.lang.RuntimeException: Unable to start activity
 ComponentInfo{com.masked.app/com.masked.app.mainjava}:java.lang.NullPointerException
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2705)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
 at android.app.ActivityThread.access$2300(ActivityThread.java:132)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:123)
 at android.app.ActivityThread.main(ActivityThread.java:4669)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:521)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
 at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
 at com.masked.app.mainjava.onCreate(mainjava.java:53)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)

At line 132 there is "adblockcheck();" that can be found here How to prevent ad blocker from blocking ads on an app ; line 123 is also within this code.

At line 53 a mediaplayer is started (mp.start();) with a starting sound.

What is the problem exactly, and why don't i get the error on my devices? This is my first error report through google play, is one error problematic or are there more developers that experience errors and don't always care about them?

Full Mainjava.java can be downloaded here http://homepage.tudelft.nl/78u5u/main.zip

EDIT: R.raw.start is a mp3 file.

Community
  • 1
  • 1
John
  • 878
  • 11
  • 21

2 Answers2

2

Obviously, your MediaPlayer mp instance is null. It means that MediaPlayer.create method returned null.

As said in android documenation for create method:

Returns
  a MediaPlayer object, or null if creation failed

I think, android can't create MediaPlayer for you beacuse of lack required codecs or so on. What is format of your R.raw.start file? You can try to play with formats. Whatever, you need to gracefuly handle this exception.

Also, as just said before, I advice you to use ACRA. It can help you resolve problems quickly. By my expirence, Android users don't like to send error reports. Less than 10% of errors are reported to the google play.

UPDATE: ACRA is good enough, but not perfect, because of blocking. It means that if app is just crashed and user have slow internet connection, you can get the ANR message. Let imagine: User thinks that app is just hang, and decided to wait for app response and then gets "Sorry, app crashed" message. You must find the way to send reports via background service or so on before using ACRA.

Also, Google Docs - default backend for sending errors - is awful. It is highly recommended to use another backend. If your app is small enough and you think you will receive less 500 error reports in a month you can try proprietary BugSense, it is supports ACRA.

pepyakin
  • 2,217
  • 19
  • 31
  • Yes, i think, you can. But, you must at least notify your user that something goes wrong. Yep, i think, it is not related to this update. Also, did you check from which app version error report came? – pepyakin Aug 02 '12 at 15:03
  • it was from the new version. the music file is mp3 – John Aug 02 '12 at 15:14
  • But is the mediaplayer returning null definitely the problem here? Because the first error line is 132? – John Aug 02 '12 at 15:17
  • 1
    First. At line 132 in my instance of mainjava.java is } char. Second, i cant find 132 line in your error stacktrace (i see one in ActivityThread.access$2300(ActivityThread.java:132)). Third, yes, i definitely sure that NullPointerException that crashed your app throwed from the mainjava.java:53 (mp.start();) – pepyakin Aug 02 '12 at 15:24
1

It's going to be hard to tell what is really going on without seeing (at least) your whole onCreate() method in com.masked.app.mainjava. It sounds like you didn't initialize your media player.

If anyone else is having trouble with crash reports, this is an AMAZING way to get better feedback on Android is this project: http://code.google.com/p/acra/

EDIT:

Your problem is almost certainly caused by the a codec issue (your device cannot play the given resource due to its filetype/format). What type of sound file is it?

You can get around your issue by changing this block:

if (startsoundint == 1){
    MediaPlayer mp = MediaPlayer.create(Mainjava.this, R.raw.start);
    if (mp != null) // null check
    {
        mp.start();
    }
}

And yes, this means it's probably not a new bug, unless you changed the sound file.

xbakesx
  • 13,202
  • 6
  • 48
  • 76
  • added the full java at the end of the questions (right click, save as) – John Aug 02 '12 at 14:17
  • I'm getting a 403.1 Forbidden (IIS Webserver error) when I try to save or view that link. – xbakesx Aug 02 '12 at 14:19
  • ACRA is great, but if you hook up ACRA to send crash reports to BugSense (https://www.bugsense.com/), you get great summary and visualization information for free. (I'm not affiliated with them besides being a happy customer) – theelfismike Aug 02 '12 at 15:07
  • this could be the wright answer, adding else{toast to user} to inform to user. But is the mediaplayer returning null definitely the problem here? Because the first error line is 132? – John Aug 02 '12 at 15:15
  • i am still surprised about the error, who has a smartphone that is unable to play an mp3 file... (regarding the codec problem) – John Aug 02 '12 at 16:30
  • That does seem odd. John, you mentioned it's a new mp3 file, is it possibly corrupt? Maybe some mp3 players can deal with some level of mp3 corruptness better than Android's MediaPlayer? http://stackoverflow.com/questions/7882851/mediaplayer-create-always-returns-null – xbakesx Aug 02 '12 at 17:34
  • it is not a new mp3 file, it was their all along – John Aug 03 '12 at 01:59
  • Are you testing it on an HTC Hero by chance? That one seems to have some MediaPlayer create issues... The other thing you can try is doing a while (mp == null) { mp.create(...); } and see if it's a timing issue or if it ever returns non-null. (Also keep in mind that will infinite loop if it never returns a non-null value). – xbakesx Aug 03 '12 at 13:57