'Android Studio Failed to resolve: org.junit.jupiter:junit-jupiter:

When i try to sync my project or run a unit test it shows me the following error: Failed to resolve: org.junit.jupiter:junit-jupiter: Affected Modules: app These are my dependencies:

plugins {
id 'com.android.application'

}

android { compileSdkVersion 30 buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.example.catalyst"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'


implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
androidTestImplementation 'org.junit.jupiter:junit-jupiter'

androidTestImplementation 'org.testng:testng:6.9.6'

}



Solution 1:[1]

I have met the same problem. The first comment gives me some tips. But it is not all for the answer. firstly we should add the junit dependencies.

 testImplementation 'junit:junit:{your version}'

then delete the org.junit.jupiter:junit-jupiter dependencies.

for me, it works well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lenoarod