Open lminsu opened 15 hours ago
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.movietrailer/com.example.movietrailer.MainActivity}: java.lang.IllegalStateException: Can't access ViewModels from detached fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3654)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
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:2267)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.IllegalStateException: Can't access ViewModels from detached fragment
at androidx.fragment.app.Fragment.getViewModelStore(Fragment.java:398)
at androidx.lifecycle.ViewModelProvider.<init>(ViewModelProvider.kt:127)
at com.example.movietrailer.ui.pager.PagerFragment.makePagerViewModel(PagerFragment.kt:105)
at com.example.movietrailer.ui.pager.PagerFragment.<init>(PagerFragment.kt:27)
at com.example.movietrailer.MainActivity.onCreate(MainActivity.kt:17)
at android.app.Activity.performCreate(Activity.java:7963)
at android.app.Activity.performCreate(Activity.java:7952)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3629)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
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:2267)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
...
프래그먼트에 생성자 인자를 추가하면 가로모드 회전 시 에러 발생
com.example.movietrailer/com.example.movietrailer.MainActivity
}: ⚠️Unable to instantiate fragmentcom.example.movietrailer.ui.main.MainFragment
: ⚠️could not find Fragment constructorperformLaunchActivity()
함수 내부 catch 문에서 Exception 발생시킴performLaunchActivity()
함수 내부 try~catch 문에서 에러가 발생하여 catch 문을 타는데, 이때 if 문에 걸려 Exception을 throw 함com.example.movietrailer.ui.main.MainFragment
: could not find Fragment constructor