09/28 20:43:56: Launching 'app' on Pixel 3a XL1 API 26. Install successfully finished in 4 s 64 ms. $ adb shell am start -n "com.example.fragment_communication_we1/com.example.fragment_communication_we1.StudentDetailsActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 24447 on device 'Pixel_3a_XL1_API_26 [emulator-5554]'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/zygote: Not late-enabling -Xcheck:jni (already on) W/zygote: Unexpected CPU variant for X86 using defaults: x86 D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.fragment_communication_we1, PID: 24447 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fragment_communication_we1/com.example.fragment_communication_we1.StudentDetailsActivity}: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class androidx.fragment.app.FragmentContainerView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class androidx.fragment.app.FragmentContainerView Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class androidx.fragment.app.FragmentContainerView Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment android.navigation.fragment.NavHostFragment: make sure class name exists at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:97) at androidx.fragment.app.Fragment.instantiate(Fragment.java:611) at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57) at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:483) at androidx.fragment.app.FragmentContainerView.(FragmentContainerView.java:175) at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:52) at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135) at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319) at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195) at com.masai.fragment_communication_we1.StudentDetailsActivity.onCreate(StudentDetailsActivity.java:17) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: java.lang.ClassNotFoundException: android.navigation.fragment.NavHostFragment at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:453) E/AndroidRuntime: at androidx.fragment.app.FragmentFactory.loadClass(FragmentFactory.java:53) at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:94) ... 30 more Caused by: java.lang.ClassNotFoundException: Didn't find class "android.navigation.fragment.NavHostFragment" on path: DexPathList[[zip file "/data/app/com.example.fragment_communication_we1-EmNvUY7d7SPFTv3-S2408g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.fragment_communication_we1-EmNvUY7d7SPFTv3-S2408g==/lib/x86, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 34 more
CodePudding user response:
Your error says:
Caused by: android.view.InflateException: Binary XML file line #13:
Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: androidx.fragment.app.Fragment$InstantiationException:
Unable to instantiate fragment android.navigation.fragment.NavHostFragment:
make sure class name exists
Your XML says android.navigation.fragment.NavHostFragment
- you've forgotten the 'x' in androidx
. It should be androidx.navigation.fragment.NavHostFragment
.