开发者

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

开发者 https://www.devze.com 2023-01-07 01:35 出处:网络
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 that it doesn\'t work anymore.

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 that it doesn't work anymore.

The error I see in the logs is:

07-14 10:33:44.016: WARN/ActivityManager(78): Unable to launch app ... 
for broadcast Intent { act=android.appwidget.action.APPWIDGET_ENABLED 
cmp=... }: process is bad 
07-14 10:33:44.026: WARN/ActivityManager(78): finishReceiver called 
but none active 
07-14 10:33:44.026: WARN/ActivityManager(78): Unable to launch app ... 
for broadcast Intent { act=android.appwidget.action.APPWIDGET_UPDATE 
cmp=... (has extras) }: process is bad 
07-14 10:33:44.036: WARN/ActivityManager(78): finishReceiver called 
but none active 

I have searched, but I cannot find anywhere what the 开发者_运维知识库process is bad error means, so I have no clue on how to fix it. Restarting the phone (or emulator) makes the error go away, however, that is not what I want my users to do. Could someone please help me to explain what the cause of the error is and how to fix it?


Happened to me when my BroadcastReceiver was repeatedly leaking an exception causing the system to kill my app. The next calls to the receiver would result in the "process is bad" logs.

The solution in my case was making sure no exceptions leak from the BroadcastReceiver.

Those are the logs when the app is killed (try looking for them and finding the cause):

W/ActivityManager﹕ Process com.company.app has crashed too many times: killing!
I/ActivityManager﹕ Killing proc 9344:com.company.app/u0a10239: crash


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.


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.


I hit a process is bad error on my HTC Sensation OS 2.3.4 after removing the INTERNET permission from my AndroidManifest.xml.

W/ActivityManager( 253): Unable to launch app MY_DOMAIN.flashback/10132 for broadcast Intent { act=android.intent.action.PHONE_STATE flg=0x20000000 (has extras) }: process is bad

I carefully tried lots of different workarounds, and I found the only way to fix was:

  • Uninstall the app through Settings -> Applications.
  • Remove the battery from the phone (using the Android "Power off" menu did not work).
  • Turn device on again.
  • Install the APK again using adb install <myapp>.

I want to take this opportunity to list what did NOT work for me (as there seems to a lot of FUD about how to fix this error):

  • Uninstall app, reboot using Android phone menu (press and hold on button and choose "Power off"), turn on again, reinstall.
  • Uninstall, use adb kill-server, then adb start-server, reinstall.
  • Uninstall, run adb shell then ps, this didn't show my app running at all.
  • Uninstall, do a clean build in Eclipse, reinstall.

I wonder if the underlying problem was caused by my app getting smaller in size. I think it used to unpack to flashback-1.apk and flashback-2.apk on the device, whereas now it is only unpacking to a single flashback-1.apk.


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.


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.


The "process is bad" is due to multiple crashes of the app (or BroadcastReceiver, Service, or other component). After a few of these the system decides it's fed up with that behavior and prevents the process from starting again.

A reboot will clear the crash count but it can also be cleared by killing the system server:

adb shell killall system_server

This will effectively do a "soft reboot." I find it much quicker than an actual reboot.


i got mine fixed like this:

uninstall the application and install it again.

i got this error when i installed a "test" application with the same package name and messed up something in the app cache data or somewhere.


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.


The problem for me was also had to do with the XML- specifically I had a TextView element that did not specify layout_width and layout_height because they were inheriting a style that did not contain them. My styles.xml file was not validated for this by eclipse. When I ran the app I got the error that these views must be specified- when I fixed the error, I received the process is bad error, and had to Force Quit.

Unfortunately I think that some settings were maintained, so rebuilding the app was not enough after the fix. I had to uninstall the app-- reboot the phone (to eliminate som persistent data) and when I reinstalled I recovered from the error.


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!");
}


I had the same problem. I got to a point where restarting and reinstalling the application didn't solve the problem. I was frustrated. I removed everything from the class that extended AppWidgetProvider, and run the application with only two empty methods in it: onUpdate and onReceive. Finally solved the problem.

Maybe it will not solve yours, but who knows. Give it a try.


This worked for me! Change your implicit intent to explicit intent, because starting Oreo implicit intents don't run in background! So basically when creating your Intent object, pass in the class name you want to start. https://developer.android.com/about/versions/oreo/background.html


I had the same problem with my project. I think it worth pointing out that I could fix this problem magically just by removing some new lines from my code in Eclipse. As an example I changed the following code,

Intent clickIntent = new Intent(this.getApplicationContext(),
MyWidgetProvider.class);

to

Intent clickIntent = new Intent(this.getApplicationContext(),MyWidgetProvider.class);
0

精彩评论

暂无评论...
验证码 换一张
取 消