importing Fragment and FragmentTransaction error

Issue

when I am trying to import these two lines in my code
"import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;"
showing error like cannot resolve symbol fragment.

Solution

Did you declare the dependencies in the Gradle?

It´s the first thing you need to do before an import.

Try this:

dependencies {

// Java language implementation
    implementation "androidx.fragment:fragment:$fragment_version"
// Kotlin
    implementation "androidx.fragment:fragment-ktx:$fragment_version"
}

And check out this link! Fragments Info

Answered By – L3G3ND

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published