I faced the below crash when reviewing another PR.
2021-11-22 17:37:10.425 14767-14767/com.woocommerce.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.woocommerce.android, PID: 14767
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:558)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.woocommerce.android.viewmodel.NavArgsLazy.getValue(SavedStateHandleExt.kt:41)
at com.woocommerce.android.viewmodel.NavArgsLazy.getValue(SavedStateHandleExt.kt:22)
at com.woocommerce.android.ui.products.ProductImagesViewModel.getNavArgs(ProductImagesViewModel.kt:44)
at com.woocommerce.android.ui.products.ProductImagesViewModel.<init>(ProductImagesViewModel.kt:45)
at com.woocommerce.android.DaggerWooCommerceDebug_HiltComponents_SingletonC$ViewModelCImpl$SwitchingProvider.get(DaggerWooCommerceDebug_HiltComponents_SingletonC.java:4400)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$1.create(HiltViewModelFactory.java:100)
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69)
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:84)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:109)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:171)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:139)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:44)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:31)
at com.woocommerce.android.ui.products.ProductImagesFragment.getViewModel(ProductImagesFragment.kt:70)
at com.woocommerce.android.ui.products.ProductImagesFragment.onViewCreated(ProductImagesFragment.kt:96)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3019)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:551)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1374)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2841)
at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2777)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3020)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:551)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1374)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2841)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2784)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:262)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:478)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:246)
at com.woocommerce.android.ui.main.AppUpgradeActivity.onStart(AppUpgradeActivity.kt:70)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
at android.app.Activity.performStart(Activity.java:8076)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3660)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
2021-11-22 17:37:10.426 14767-14767/com.woocommerce.android E/AndroidRuntime: at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7838)
... 3 more
Caused by: java.lang.ClassCastException: android.os.Parcelable[] cannot be cast to com.woocommerce.android.model.Product$Image[]
at com.woocommerce.android.ui.products.ProductImagesFragmentArgs$Companion.fromSavedStateHandle(ProductImagesFragmentArgs.kt:116)
at com.woocommerce.android.ui.products.ProductImagesFragmentArgs.fromSavedStateHandle(Unknown Source:2)
To reproduce
Enable Do not keep activities.
Click on the Products tab and click on a product.
Click on add image icon.
Click on Choose from device option.
Either pick media from the media picker or choose from the device.
Notice the app crashes as soon as you choose an image and click done.
I faced the below crash when reviewing another PR.
To reproduce
Do not keep activities
.Choose from device
option.