App crashes - Unable to start activity ComponentInfo
KhoiHuynh opened this issue · 2 comments
KhoiHuynh commented
- I have a
MainActivity
that implementsBaseFragment
. - In my
MainActivity
, i have 3 fragments that all implement theBaseFragment
. They are all navigated via theBottomNavigationView
widget - In one of my fragments, i create an activity when a user clicked a button"
val intent = Intent(activity, RentActivity::class.java)
intent.putExtra("bundle", bundle)
activity?.startActivity(intent)
- all is working fine so far
- In my new activity, i try opening a Dialog on a button click:
private fun OpenDialog() {
var dialog = Dialog(this)
dialog.setContentView(R.layout.stripe_layout)
var lp : WindowManager.LayoutParams = WindowManager.LayoutParams().apply {
copyFrom(dialog.window.attributes)
width = WindowManager.LayoutParams.MATCH_PARENT
height = WindowManager.LayoutParams.WRAP_CONTENT
}
...
- This is when the app crashes and gives me the following stacktrace:
2019-03-12 11:30:12.104 19906-19906/com.example.khoi.parkingapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.khoi.parkingapp, PID: 19906
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.khoi.parkingapp/com.example.khoi.parkingapp.activities.MainActivity}: java.lang.IllegalStateException: savedInstanceState.getSt…g(EXTRA_CURRENT_FRAGMENT) must not be null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: savedInstanceState.getSt…g(EXTRA_CURRENT_FRAGMENT) must not be null
at com.ncapdevi.fragnav.FragNavController.restoreFromBundle(FragNavController.kt:792)
at com.ncapdevi.fragnav.FragNavController.initialize(FragNavController.kt:187)
at com.example.khoi.parkingapp.activities.MainActivity.onCreate(MainActivity.kt:180)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
any help would be appreciated
ncapdevi commented
Hmm, I think you're doing something strange with your navigation. You say you're switching to a new Activity, but this error is coming from your MainActivity calling OnCreate
again.
Also, can you verify which version of the library you are on?
ncapdevi commented
Haven't heard anything back, so closing this for now.