我有一个私人公司应用,今天收到了一份异常的崩溃报告。我以前从未见过类似的东西,在Google搜索中找不到任何匹配项,到目前为止,仍无法复制。有问题的代码在10月份生效,员工在完成工作或换班时每天大约要经过40次。
该应用已针对SDK 28(9.0)进行了编译,崩溃发生在8.1.0。
我已经从原始代码中修改了以下代码片段,以通用化/简化名称并删除不相关的代码。
Stacktrace:
java.lang.IllegalArgumentException: setTaskFromSourceRecord:
task=TaskRecord{f142380 #13 A=com.example.app U=0 StackId=1 sz=2} is in a different stack (1) than the parent of
r=ActivityRecord{120fce5 u0 com.sec.android.app.launcher/.activities.LauncherActivity t14} (0) at
android.os.Parcel.readException(Parcel.java:2033) at
android.os.Parcel.readException(Parcel.java:1975) at
android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4822) at
android.app.Instrumentation.execStartActivity(Instrumentation.java:1619) at
android.app.Activity.startActivityForResult(Activity.java:4621) at
androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767) at
androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234) at
androidx.fragment.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:881) at
androidx.fragment.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:995) at
androidx.fragment.app.Fragment.startActivity(Fragment.java:1084) at
androidx.fragment.app.Fragment.startActivity(Fragment.java:1073) at
com.example.app.PunchOutFragment.goHome(PunchOutFragment.java:234) at
com.example.app.PunchOutFragment.access$100(PunchOutFragment.java:50) at
com.example.app.PunchOutFragment$2.onReceive(PunchOutFragment.java:269) at
androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:313) at
androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:121) at
android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at
com.example.app.MyApplication.onCreate(MyApplication.java:48) at
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1127) at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:6097) at
android.app.ActivityThread.-wrap1(Unknown Source:0) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1791) at
android.os.Handler.dispatchMessage(Handler.java:106) at
android.os.Looper.loop(Looper.java:164) at
android.app.ActivityThread.main(ActivityThread.java:7000) at
java.lang.reflect.Method.invoke(Native Method) at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
PunchOutFragment.goHome():
private void goHome() {
Activity activity = requireActivity();
activity.setResult(Activity.RESULT_OK);
Intent intent = new Intent(getContext(), HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); // PunchOutFragment.java:234
activity.finish();
}
MyApplication.onCreate():
@Override
public void onCreate() {
super.onCreate();
mWeakAppContext = new WeakReference<>(getApplicationContext());
CrashHandler crashHandler = new CrashHandler();
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
try {
Looper.loop(); // MyApplication.java:48
} catch (Exception e) {
crashHandler.uncaughtException(Thread.currentThread(), e);
}
}
如果登录后从服务器检索到主动打孔,则调用其他相关代码;服务器日志表明,这是在打孔和崩溃之前大约一分钟调用的:
private void selectPunch(Punch punch) {
Context context = requireContext();
Intent intentHome = new Intent(context, HomeActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext());
stackBuilder.addParentStack(HomeActivity.class);
stackBuilder.addNextIntent(intentHome);
Intent intentPunchedIn = new Intent(context, PunchedInActivity.class);
intentPunchedIn.putExtra(PUNCH_ID, punch.id);
stackBuilder.addNextIntent(intentPunchedIn);
stackBuilder.startActivities();
requireActivity().finish();
}