当我试图同步项目或运行单元测试时,它会显示以下错误:Failed to resolve: org.junit.jupiter:junit-jupiter: Affected Modules: app --这是我的依赖项:
plugins {
id 'com.android.application'}
安卓{ 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
}}
依赖关系{
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'}
发布于 2022-05-05 09:46:27
我也遇到过同样的问题。第一条评论给了我一些建议。但这并不是全部的答案。首先,我们应该添加junit依赖项。
testImplementation 'junit:junit:{your version}'然后删除org.junit.jupiter:junit-jupiter依赖项。
对我来说,效果很好。
https://stackoverflow.com/questions/67379300
复制相似问题