We use our app on only one device type and we get this error pretty often on it.
The only instance for PackageManager is a BootupReceiver:
public class RestartHelper extends BroadcastReceiver
{
#Override
public void onReceive(Context context, Intent intent) {
Logger.getInstance().Log("Restart received");
Intent i = context.getPackageManager().getLaunchIntentForPackage( context.getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i);
}
}
Exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.MainActivity}: java.lang.RuntimeException: Package manager has died
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:239)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:301)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:281)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:152)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at com.cotris.roosapp.StandardActivity.onCreate(StandardActivity.java:49)
at com.cotris.roosapp.MainActivity.onCreate(MainActivity.java:64)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Caused by: android.os.DeadObjectException
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.getActivityInfo(IPackageManager.java:1791)
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:234)
... 20 more
Is this error hardware/system related?
Obviously there has another PackageManger call but not only in RestartHelper.java:
at com.cotris.roosapp.StandardActivity.onCreate(StandardActivity.java:49)
You man need to check the code detail in that.
The android.os.DeadObjectException means that you link to something, that does not exist any more.
the solution for my case was a hardware related problem, which created all kind of crashes of system processes in the background on the device.
Related
I'm getting the DeadObjectException from queryIntentActivities rarely.
This is all I found for this issue: http://comments.gmane.org/gmane.comp.handhelds.android.acra/184 So I tried to adjust my code like following (comment in this code is derived from the post mentioned above).
I'm trying following:
Old code
List<ResolveInfo> ril = pm.queryIntentActivities(mainIntent, 0);
New code
List<ResolveInfo> ril = null;
try
{
ril = pm.queryIntentActivities(mainIntent, 0);
// process data...
}
catch (DeadObjectException e)
{
// possibly happens because this process is still running but app is currently being updated by the android system
// if this is really true, we can ignore the exception as the complete progress will be stopped anyways...
L.e(e);
}
Problem
I can't catch the exception, because by definition it is never thrown by queryIntentActivities. What can I do instead now to avoid this crash? I don't want to catch all exceptions here.
Additionally I'm not sure if this exception really only happens, I've my app is updated while trying to call queryIntentActivities, it's just an assumption based on the post above. Can anyone confirm this?
Stacktrace
java.lang.RuntimeException: Unable to start receiver com.my.app.receivers.PackageReceiver: java.lang.RuntimeException: Package manager has died
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3641)
at android.app.ActivityThread.access$2000(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1876)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:765)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:747)
at com.my.app.utils.AppUtil.a(AppUtil.java:230)
at com.my.app.receivers.PackageReceiver.onReceive(PackageReceiver.java:42)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3634)
... 8 more
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:3940)
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:755)
... 12 more
java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:765)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:747)
at com.my.app.utils.AppUtil.a(AppUtil.java:230)
at com.my.app.receivers.PackageReceiver.onReceive(PackageReceiver.java:42)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3634)
at android.app.ActivityThread.access$2000(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1876)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:3940)
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:755)
... 12 more
android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:3940)
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:755)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:747)
at com.my.app.utils.AppUtil.a(AppUtil.java:230)
at com.my.app.receivers.PackageReceiver.onReceive(PackageReceiver.java:42)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3634)
at android.app.ActivityThread.access$2000(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1876)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
This question already has answers here:
android app crash on android 4.4 due to gps permission denial
(2 answers)
Closed 6 years ago.
This is my code:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
}
This is the error in logcat:
FATAL EXCEPTION: main
Process: com.example.satyajittarafdar.gps_on_automatic, PID: 20469
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.satyajittarafdar.gps_on_automatic/com.example.satyajittarafdar.gps_on_automatic.MainActivity}:
java.lang.SecurityException: Permission Denial: not allowed to send
broadcast android.location.GPS_ENABLED_CHANGE from pid=20469,
uid=10240
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2429)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.SecurityException: Permission Denial: not allowed
to send broadcast android.location.GPS_ENABLED_CHANGE from pid=20469,
uid=10240
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at
android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3128)
at android.app.ContextImpl.sendBroadcast(ContextImpl.java:767)
at
android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:396)
at
com.example.satyajittarafdar.gps_on_automatic.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:6259)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2382)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
This is not available as public API, and you cannot change GPS state programmatically from Android 4.4 and above. you have prepare intent and redirect user to settings.
startActivity(context, new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
here are some references:
https://stackoverflow.com/a/22529296/3758024
https://stackoverflow.com/a/20236331/3758024
You cannot change the gps state programmaticly since android version 4.4.
Good explanation why: Read this post
What you should so is using intent to send the user to the phoen setting and request him to enable it manually.
I am trying to make an app based on Cordova that is able to send Notifications via FireBase Cloud Messaging
Here the MainActivity.java
public class MainActivity extends CordovaActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
Intent i=new Intent(this,NotificationService.class);
startService(i);
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
Helper mhelper=new Helper(this,appView);
FirebaseMessaging.getInstance().subscribeToTopic("Testing");
Log.d("Message","Subscribed To Testing");
Log.d("Token",FirebaseInstanceId.getInstance().getToken());
loadUrl(launchUrl);
}
}
However I am getting a Illegal State Exception at Line 49:
FirebaseMessaging.getInstance().subscribeToTopic("Testing");
The rest Manifest.xml etc. are the same as the sample provided here
https://github.com/firebase/quickstart-android/tree/master/messaging
In the Logcat, the error it is showing is::
FATAL EXCEPTION: main
Process: careerage.jobseeker.app, PID: 5764
java.lang.RuntimeException: Unable to start activity ComponentInfo{careerage.jobseeker.app/careerage.jobseeker.app.MainActivity}: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
at android.app.ActivityThread.access$900(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.google.firebase.messaging.FirebaseMessaging.getInstance(Unknown Source)
at careerage.jobseeker.app.MainActivity$override.onCreate(MainActivity.java:49)
at careerage.jobseeker.app.MainActivity$override.access$dispatch(MainActivity.java)
at careerage.jobseeker.app.MainActivity.onCreate(MainActivity.java:0)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
at android.app.ActivityThread.access$900(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
I tried java.lang.IllegalStateException: FirebaseApp with name [DEFAULT]
but still it doesn't recognize FirebaseDatabase Class
Try updating your dependency to:
compile 'com.google.firebase:firebase-messaging:9.0.2'
This bug was fixed in patches between 9.0.0 and 9.0.2
I think Fcm and Gcm take some time to get tokens.. If you try to do anything with cloud messaging without the token being assigned you will get error.
I am making the following call:
Intent launchIntent = context.getPackageManager()
.getLaunchIntentForPackage(packageName);
It crashes with NPE with the following stackTrace:
java.lang.NullPointerException at
android.app.Instrumentation.execStartActivity(Instrumentation.java:1423)
at android.app.Activity.startActivityForResult(Activity.java:3584) at
android.app.Activity.startActivityForResult(Activity.java:3545) at
android.support.v4.app.FragmentActivity.void
startActivityForResult(android.content.Intent,int)(SourceFile:817) at
android.app.Activity.startActivity(Activity.java:3787) at
android.app.Activity.startActivity(Activity.java:3755) at
utils.AppsLauncher.voidlaunchApp(android.content.Context,java.lang.String)(SourceFile:100)
at utils.AppsLauncher.void
launchAppIfInstalledOtherwiseMarket(android.app.Activity,java.lang.String,utils.AppReportingParams)(SourceFile:73)
at utils.AppsLauncher.void
launchAppIfInstalledOtherwiseMarket(android.app.Activity,java.lang.String)(SourceFile:51)
at adapters.BaseGamesListAdapter.void
launchAppIfInstalledOtherwiseMarket(java.lang.String)(SourceFile:119)
at
adapters.UserGamesAdapter$UserGameUIHolder$1.void
onClick(android.view.View)(SourceFile:198) at
android.view.View.performClick(View.java:4658) at
android.view.View$PerformClick.run(View.java:19461) at
android.os.Handler.handleCallback(Handler.java:733) at
android.os.Handler.dispatchMessage(Handler.java:95) at
android.os.Looper.loop(Looper.java:146) at
android.app.ActivityThread.main(ActivityThread.java:5692) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:515) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at
dalvik.system.NativeStart.main(Native Method)
I assume that getLaunchIntentForPackage(packageName) returns a null Intent. I can't figure out in GREPcode why exactly it returns null: (http://grepcode.com/file/repo1.maven.org/maven2/org.robolectric/android-all/5.0.0_r2-robolectric-0/android/app/ApplicationPackageManager.java#ApplicationPackageManager.getLaunchIntentForPackage%28java.lang.String%29)
It is important to note that the package does indeed exist and is installed on the device.
The context or context.getPackageManager() is null.
I am starting different apps like phone app, browser app, maps app from my app something like this
String url = "http://www." + textView.getText().toString();
Log.d(TAG,url);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
mContext.startActivity(i);
At first they worked perfectly but now every app crashes like
"unfortunetly chorme stopped working" or "unfortunetly dialer has stopped working" etc. I hope some one knows why its happening. Thanks in advance.
This is my logcat
05-08 19:12:28.720 10227-10227/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.google.android.apps.maps, PID: 10227
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.apps.maps/com.google.android.maps.MapsActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.krishnateja.bigapplesearch.models.MTAMainScreenModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.krishnateja.bigapplesearch.models.MTAMainScreenModel
at android.os.Parcel.readParcelableCreator(Parcel.java:2289)
at android.os.Parcel.readParcelable(Parcel.java:2239)
at android.os.Parcel.readValue(Parcel.java:2146)
at android.os.Parcel.readListInternal(Parcel.java:2520)
at android.os.Parcel.readArrayList(Parcel.java:1836)
at android.os.Parcel.readValue(Parcel.java:2167)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.BaseBundle.getIntArray(BaseBundle.java:1164)
at android.content.Intent.getIntArrayExtra(Intent.java:5004)
at com.google.android.apps.gmm.m.l.a(PG:1061)
at com.google.android.apps.gmm.m.w.a(PG:2241)
at com.google.android.apps.gmm.base.activities.a.onNewIntent(PG:953)
at com.google.android.apps.gmm.base.activities.a.onCreate(PG:641)
at android.app.Activity.performCreate(Activity.java:5953)
at
The reason for the class not found is I am overiding start activity for some other intent but I did not have an if condition saying add extra to the particular intent. A silly mistake.