1
votes

I tried to sync my project in android studio with gradle files but it failed and I got the above message "Grade sync failed: Unresolved dependencies".

I also got these errors in the build tab:

  1. ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.fragment:fragment:[1.2.0].
    Show Details
    Affected Modules: app
  2. ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.fragment:fragment:[1.2.0].
    Show Details
    Affected Modules: app
  3. ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.fragment:fragment:[1.2.0].
    Show Details
    Affected Modules: app

These are my dependencies in build.gradle (Module:app)

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
1
Delete implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' - MMG
@MohammadMoeinGolchin I deleted the implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' , but after I still got an error: ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not download fragment.aar (androidx.fragment:fragment:1.1.0) Show Details Affected Modules: app - Dappa jack

1 Answers

4
votes

Hey I am not very much sure of this I didn't find any dependency for fragment

dependencies {
    def fragment_version = "1.2.4"

    // Java language implementation
    implementation "androidx.fragment:fragment:$fragment_version"
    // Kotlin
    implementation "androidx.fragment:fragment-ktx:$fragment_version"
    // Testing Fragments in Isolation
    implementation "androidx.fragment:fragment-testing:$fragment_version"

}

Put this in the dependencies section