简体   繁体   中英

Play developer console: 2 error reports on 13k active users

I have a small question as a starting developer. I've created an app that has been downloaded quite a lot last 2 weeks and has 13k active users. I've tested this on a few (Samsung) phones and of course in the emulator. I can't generate any errors, since the app is simple I wasn't expecting it to do so.

But today I've looked into my Play Developer Console and found 2 error reports. Is this something that I should be concerned about or can this errors be randomly generated? I know for example that bad custom roms can create a crash, I've experienced this myself.

I will post the class that created this, this plays a selected sound when a button is clicked. One of the crashes in a nullPointerException when the button was clicked, the other was a illegalStateException that was generated when mp.stop() was called. To me it seems not possible that this generates an error, but of course I could be wrong. This is the code:

public class SoundActivity extends Activity implements OnClickListener,
    OnCheckedChangeListener {

Button btn;
MediaPlayer mp;
RadioGroup slct;
RadioButton radio0, radio1, radio2, radio3, radio4;
int t = 1;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.btclayout);
    initialize();
    btn.setOnClickListener(this);
    slct.setOnCheckedChangeListener(this);
    mp = MediaPlayer.create(this, R.raw.sound1);

}

public void initialize() {
    btn = (Button) findViewById(R.id.button1);
    slct = (RadioGroup) findViewById(R.id.radioGroup1);
    radio0 = (RadioButton) findViewById(R.id.radio0);
    radio1 = (RadioButton) findViewById(R.id.radio1);
    radio2 = (RadioButton) findViewById(R.id.radio2);
    radio3 = (RadioButton) findViewById(R.id.radio3);
    radio4 = (RadioButton) findViewById(R.id.radio4);

}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    mp.stop();
    mp.reset();
    switch (t) {
    case 1:
        mp = MediaPlayer.create(this, R.raw.sound1);
        break;
    case 2:
        mp = MediaPlayer.create(this, R.raw.sound2);
        break;
    case 3:
        mp = MediaPlayer.create(this, R.raw.sound3);
        break;
    }
    mp.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    mp.release();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    mp = MediaPlayer.create(this, R.raw.sound1);
}

@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
    // TODO Auto-generated method stub
    switch (arg1) {
    case R.id.radio0:
        t = 1;
        break;
    case R.id.radio1:
        t = 2;
        break;
    case R.id.radio2:
        t = 3;
        break;
    case R.id.radio3:
        t = 4;
        break;
    case R.id.radio4:
        t = 5;
        break;
    }
}
}

Edit: This are the stacktraces from the Play Console:

java.lang.IllegalStateException at android.media.MediaPlayer._stop(Native Method) at android.media.MediaPlayer.stop(MediaPlayer.java:1033) at com.ddroid.DisMyApp.SoundActivity.onClick(SoundActivity.java:57) at android.view.View.performClick(View.java:3549) at android.view.View$PerformClick.run(View.java:14400) at android.os.Handler.handleCallback(Handler.java:605) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:4944) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method)

The second one:

java.lang.NullPointerException at com.ddroid.DisMyApp.SoundActivity.onClick(SoundActivity.java:76) at android.view.View.performClick(View.java:2538) at android.view.View$PerformClick.run(View.java:9152) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) at dalvik.system.NativeStart.main(Native Method)

While these errors should not happen, it's been my experience that users will always find a way to crash your application in unintended ways :) In each of these failures, it happened in the onClick() , so I would wrap the onClick() code inside a try/catch and then simply log the error. The fact that you are seeing the error in your developer console means that the user experienced a Force Close issue, so trapping the error is certainly better.

In many State related issues that I've seen, it's mainly to with the the user performing an operation while doing a rotate on the device at the same time. Sometimes using the Android Monkey can randomly simulate these kinds of errors as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM