I have a strange problem, 95% of my devices doesn't have this problem, but a few devices crash and report this error:
Exception java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3751)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3919)
at android.app.ActivityThread.handleRelaunchActivityInner (ActivityThread.java:5896)
at android.app.ActivityThread.handleRelaunchActivity (ActivityThread.java:5781)
at android.app.servertransaction.ActivityRelaunchItem.execute (ActivityRelaunchItem.java:71)
at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
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:2311)
at android.os.Handler.dispatchMessage (Handler.java:111)
at android.os.Looper.loopOnce (Looper.java:238)
at android.os.Looper.loop (Looper.java:357)
at android.app.ActivityThread.main (ActivityThread.java:8090)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1026)
Caused by androidx.fragment.app.o$c:
at androidx.fragment.app.Fragment.instantiate (Fragment.java:8)
at androidx.fragment.app.FragmentContainer.instantiate (FragmentContainer.java:8)
at androidx.fragment.app.FragmentManager$2.instantiate (FragmentManager.java:8)
at androidx.fragment.app.FragmentState.instantiate (FragmentState.java)
at androidx.fragment.app.FragmentStateManager.<init> (FragmentStateManager.java)
at androidx.fragment.app.FragmentManager.restoreSaveStateInternal (FragmentManager.java:8)
at androidx.fragment.app.FragmentManager.attachController (FragmentManager.java:9)
at androidx.fragment.app.FragmentController.attachHost (FragmentController.java:2)
at androidx.fragment.app.FragmentActivity.lambda$init$1 (FragmentActivity.java:2)
at androidx.fragment.app.FragmentActivity$$InternalSyntheticLambda$0$ff06e2d7bdf291226d37b4353b1605437624ba3a9eae3873db87597251a20577$1.onContextAvailable (FragmentActivity.java:2)
at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable (ContextAwareHelper.java:1)
at androidx.activity.ComponentActivity.onCreate (ComponentActivity.java:1)
at androidx.fragment.app.FragmentController.dispatchCreate (FragmentController.java)
at com.buzinc.animecosmos.databinding.ActivityAnimeResolverBinding.inflate (ActivityAnimeResolverBinding.java)
at android.app.Activity.performCreate (Activity.java:8232)
at android.app.Activity.performCreate (Activity.java:8212)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1331)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3724)
Caused by java.lang.NoSuchMethodException:
at java.lang.Class.getConstructor0 (Class.java:2363)
at java.lang.Class.getConstructor (Class.java:1759)
at androidx.fragment.app.Fragment.instantiate (Fragment.java:4)
at androidx.fragment.app.FragmentContainer.instantiate (FragmentContainer.java:4)
at androidx.fragment.app.FragmentManager$2.instantiate (FragmentManager.java:4)
What should I do? I have read some question similar but nothing has solved the problem. My app as an activity that programmatically change screen orientation and start a fragment. The fragment make the app crash, I tested the app without screen rotation, in which case the app does not crash. Thanks to everyone