How to fix “process is bad” error for an Android Widget?

前端 未结 14 860
太阳男子
太阳男子 2020-12-02 07:44

I have developed an Android Widget, and it was working fine. I added some extra functionality and pushed an update through the Android Market. Now people are complaining tha

相关标签:
14条回答
  • 2020-12-02 08:19

    I am having the same problem and my current theory is that the appWidget crashed and when it was restarted it had the same bad persistent data that made it crash each time it was restarted. When this happens too often, the appWidget is "force stopped" by the OS. My band aid is to have a touch event that is "setOnClickPending" that the user will touch (out of frustration if necessary) and that will be processed internal to the appWidget and reset the appWidget.

    0 讨论(0)
  • 2020-12-02 08:21

    I just get this error. I fix the error and I remove some source code invoking from OnConnectionReceiver.onReceiver(), Maybe the invocation will cost some time.

    0 讨论(0)
  • 2020-12-02 08:21

    I faced a similar problem . When I went through my code , I realized that it was the default values which were the culprit . Ensure that your default values are logical and positive.For instance ,if you have a background service starting at a particular interval , ensure that the default value you have set for the same is appropriate.

    0 讨论(0)
  • 2020-12-02 08:23

    I faced this problem. the reason was that the WLAN call wifi.getConnectionInfo().getScanResults(); could return a null instead of an empty list in some occations. I found this after logging the logcat for several hours. When the application encountered an error and crashed, a touch on the widget would give me the same "bad process" error you mention here as the intent did not reopen the app, but it gets stuck in a crashed state. Guess it it just the way Android deals with a crashed widget.

    0 讨论(0)
  • 2020-12-02 08:24

    I just experienced this myself right before packaging for the market place. I was following the guidelines and added the android:label="@string/app_name" attribute to the application element in my manifest...

    1. Uninstall your app
    2. Reboot phone/emulator
    3. Push new app without this attribute

    Viola! Works for me now!

    EDIT: To match comments.

    0 讨论(0)
  • 2020-12-02 08:24

    Somewhat off-topic, but in some Android devices one can reproducibly cause this failure by writing an app which creates an UncaughtExceptionHandler in onCreate to restart the app after a crash, and then does something to cause an unhandled exception (either throw a RuntimeException, or do something that causes an NullPointerException, or whatever). Some example code is given below.

    I have tried this on two devices: a Samsung Galaxy Tab 2, and a Verizon Ellipsis 7. With the Tab 2, I couldn't cause the issue while I was running the app from Eclipse -- it would crash and restart repeatedly and never be killed. Instead, I had to export the app to apk, install via adb, start the app, and after 4-8 crashes and restarts, Android would kill the app with the error message above (Process com.buggy.app has crashed too many times: killing!).

    With the Ellipsis 7, I was never able to reproduce the issue. The buggy app would repeatedly crash and restart, and the OS never killed it even after 10 minutes of this.

    Sample code for repeatedly crashing app:

    public void onCreate(Bundle savedInstanceState) {
      mContext = this.getApplicationContext();
    
      UncaughtExceptionHandler uehandler = new Thread.UncaughtExceptionHandler() {
    
        @Override
        public void uncaughtException(Thread thread, Throwable ex) {
    
          // restart app after 100 milliseconds
          PendingIntent myActivity = PendingIntent.getActivity(mContext, 0,
              new Intent(mContext, MyActivity.class),
              PendingIntent.FLAG_ONE_SHOT);
          AlarmManager alarmManager = (AlarmManager) 
              mContext.getSystemService(Context.ALARM_SERVICE);
          alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 100,
              myActivity);
    
          System.exit(2);
    
          // re-throw critical exception further to the os (important)
          Thread.getDefaultUncaughtExceptionHandler().uncaughtException(thread, ex);
        }
      };
      Thread.setDefaultUncaughtExceptionHandler(uehandler);
    
      throw new RuntimeException("Crash the app!");
    }
    
    0 讨论(0)
提交回复
热议问题