0

I have been debugging all day with no result

I get the error

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.b_hero/com.example.b_hero.MainActivity}: android.view.InflateException: Binary XML file line #9 in com.example.b_hero:layout/activity_main: Binary XML file line #9 in com.example.b_hero:layout/activity_main: Error inflating class fragment

I read Error inflating class fragment but it does not work for me

activity_main.Xml


<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        <fragment
            android:id="@+id/myNavHostFrgment"
            android:name="com.example.b_hero.SignIn.SignInFragment"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            app:navGraph="@navigation/nav_graph"
            app:defaultNavHost= "true"
            />

    </LinearLayout>

</layout> 

line #9 is the <fragment Tag

SignInFragment class

package com.example.b_hero.SignIn
import android.os.Bundle
import android.view.*
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI
import com.example.b_hero.R
import com.example.b_hero.databinding.FragmentSignInBinding

class SignInFragment : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val binding: FragmentSignInBinding =
            DataBindingUtil.inflate(inflater, R.layout.fragment_sign_in, container, false)

        binding.apply {  
  signInButton.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_signInFragment_to_signUp))
        }
        return binding.root
    }
}
theThapa
  • 581
  • 4
  • 11

1 Answers1

0
        <fragment
            android:id="@+id/myNavHostFrgment"
            android:name="com.example.b_hero.SignIn.SignInFragment"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            app:navGraph="@navigation/nav_graph"
            app:defaultNavHost= "true"
            />

Change fragment to Fragment