goldze / MVVMHabit

👕基于谷歌最新AAC架构,MVVM设计模式的一套快速开发库,整合Okhttp+RxJava+Retrofit+Glide等主流模块,满足日常开发需求。使用该框架可以快速开发一个高质量、易维护的Android应用。
Apache License 2.0
7.6k stars 1.69k forks source link

viewpager+fragment 页面启动时,报闪退的bug,大佬帮忙解决下 #78

Closed superheroLiang closed 4 years ago

superheroLiang commented 4 years ago

Build version: 3.0.0 Current date: 2020-07-01 11:00:18 Device: Xiaomi Mi 10 Pro

Stack trace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gotoschool.teacher/me.goldze.mvvmhabit.base.ContainerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.util.SparseArray.get(int)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3312) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3461) at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5367) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5275) at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2048) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:227) at android.app.ActivityThread.main(ActivityThread.java:7573) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:953) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.util.SparseArray.get(int)' on a null object reference at android.support.v4.app.FragmentManagerImpl.getFragment(FragmentManager.java:936) at me.goldze.mvvmhabit.base.ContainerActivity.onCreate(ContainerActivity.java:39) at android.app.Activity.performCreate(Activity.java:7893) at android.app.Activity.performCreate(Activity.java:7880) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3287) ... 13 more

User actions: 2020-07-01 10:58:59: SplashActivity created 2020-07-01 10:58:59: SplashActivity resumed 2020-07-01 10:59:00: SplashActivity paused 2020-07-01 10:59:00: MainActivity created 2020-07-01 10:59:00: MainActivity resumed 2020-07-01 10:59:01: SplashActivity destroyed 2020-07-01 10:59:07: MainActivity paused 2020-07-01 10:59:07: ContainerActivity created 2020-07-01 10:59:07: ContainerActivity resumed 2020-07-01 10:59:08: ContainerActivity paused 2020-07-01 10:59:08: ContainerActivity created 2020-07-01 10:59:09: ContainerActivity resumed 2020-07-01 10:59:11: ContainerActivity paused 2020-07-01 10:59:11: ContainerActivity resumed 2020-07-01 10:59:11: ContainerActivity destroyed 2020-07-01 10:59:12: ContainerActivity paused 2020-07-01 10:59:12: MainActivity resumed 2020-07-01 10:59:12: ContainerActivity destroyed 2020-07-01 10:59:14: MainActivity paused 2020-07-01 10:59:14: ContainerActivity created 2020-07-01 10:59:14: ContainerActivity resumed 2020-07-01 10:59:15: ContainerActivity paused 2020-07-01 10:59:15: ContainerActivity created 2020-07-01 10:59:15: ContainerActivity resumed 2020-07-01 10:59:17: ContainerActivity paused 2020-07-01 10:59:17: ContainerActivity created 2020-07-01 10:59:17: ContainerActivity resumed 2020-07-01 10:59:22: ContainerActivity paused 2020-07-01 10:59:22: ContainerActivity resumed 2020-07-01 10:59:22: ContainerActivity destroyed 2020-07-01 10:59:22: ContainerActivity destroyed 2020-07-01 10:59:23: ContainerActivity paused 2020-07-01 10:59:23: ContainerActivity created 2020-07-01 10:59:23: ContainerActivity resumed 2020-07-01 10:59:40: ContainerActivity paused 2020-07-01 10:59:41: ContainerActivity resumed 2020-07-01 10:59:50: ContainerActivity paused 2020-07-01 10:59:50: ContainerActivity destroyed 2020-07-01 10:59:50: ContainerActivity created