startActivity出错,但仅限于android 7设备

时间:2017-01-28 10:54:57

标签: android android-activity android-7.0-nougat android-bundle android-7.1-nougat

自从我两天前将手机(三星Galaxy S7)更新到新的Android 7.0后,我在运行我的应用时偶尔出现错误。当Activity_CstartActivity

一起开始时,它有时会出现(平均每五次一次)

java.lang.RuntimeException: Unable to start activity ComponentInfo{de.my.app/de.my.app.gui.Activity_C}: java.lang.IllegalStateException: Bad magic number for Bundle: 0x620061 (下面的完整堆栈跟踪)

Activity_C继承自Activity_BActivity_A本身继承自Activity_AAppCompatActivityandroid.support.v7.app扩展为包onCreate

活动A,B和C有protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); 方法,其开头如下:

savedInstanceState

发生错误时,null是默认startActivitycontext.startActivity(new Intent(getActivity(), Activity_C.class));调用始终相同(01-27 21:36:45.241 9953-9953/de.my.app E/AndroidRuntime: FATAL EXCEPTION: main Process: de.my.app, PID: 9953 java.lang.RuntimeException: Unable to start activity ComponentInfo{de.my.app/de.my.app.gui.Activity_C}: java.lang.IllegalStateException: Bad magic number for Bundle: 0x620061 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6688) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) Caused by: java.lang.IllegalStateException: Bad magic number for Bundle: 0x620061 at android.os.BaseBundle.readFromParcelInner(BaseBundle.java:1443) at android.os.BaseBundle.<init>(BaseBundle.java:128) at android.os.Bundle.<init>(Bundle.java:69) at android.os.Parcel.readBundle(Parcel.java:1888) at android.os.Parcel.readBundle(Parcel.java:1872) at android.content.pm.PackageItemInfo.<init>(PackageItemInfo.java:466) at android.content.pm.ApplicationInfo.<init>(ApplicationInfo.java:1311) at android.content.pm.ApplicationInfo.<init>(ApplicationInfo.java) at android.content.pm.ApplicationInfo$1.createFromParcel(ApplicationInfo.java:1303) at android.content.pm.ApplicationInfo$1.createFromParcel(ApplicationInfo.java:1302) at android.content.pm.ComponentInfo.<init>(ComponentInfo.java:228) at android.content.pm.ActivityInfo.<init>(ActivityInfo.java:1025) at android.content.pm.ActivityInfo.<init>(ActivityInfo.java) at android.content.pm.ActivityInfo$1.createFromParcel(ActivityInfo.java:1017) at android.content.pm.ActivityInfo$1.createFromParcel(ActivityInfo.java:1016) at android.content.pm.IPackageManager$Stub$Proxy.getActivityInfo(IPackageManager.java:3157) at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:484) 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.AppCompatDelegateImplV9.onCreate(AppCompatDelegateImplV9.java:157) at android.support.v7.app.AppCompatDelegateImplV14.onCreate(AppCompatDelegateImplV14.java:60) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:76) at de.my.app.gui.Activity_A.onCreate(Activity_A.java:39) at de.my.app.gui.Activity_B.onCreate(Activity_B.java:43) at de.my.app.gui.Activity_C.onCreate(Activity_C.java:50) at android.app.Activity.performCreate(Activity.java:6912) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)  at android.app.ActivityThread.-wrap14(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6688)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)  )且来自同一活动。

我搜索了几个小时,但没有发现任何有用的东西。我不是新手,也不是专家;但它看起来对我来说问题不在于我的活动,而在于android系统的东西。

我现在使用最新的sdk(25)和相应的支持包(25.1.0),但错误也发生在我之前使用过的sdk v23上。在运行Android 5或6的其他设备上,一切仍然正常。

有人知道为什么会出现这个问题以及如何处理它?<​​/ p>

这是完整的堆栈跟踪:

{{1}}

0 个答案:

没有答案