Omo*_*eun 9 java android okhttp
我试图学习如何使用 OkHTTP。我将库导入到我的项目中,但是当我编译代码时,它会出现此错误。
找不到 org.junit.jupiter:junit-jupiter:。需要者:project :app 在 build.gradle 文件中搜索。
请问我该怎么办。这是我的 build.gradle 下面
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.omolayoseun.saprktesterapp"
minSdk 23
targetSdk 32
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.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
}
Run Code Online (Sandbox Code Playgroud)
kon*_*dev 15
junit-jupiter依赖项仅用于运行 junit 5 单元测试,在您的情况下,您甚至不需要此依赖项。请随意删除它。并确保通过选择应用程序来运行项目
在运行菜单中。
一旦您决定运行实际的单元测试,请使用这些依赖项:
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
Run Code Online (Sandbox Code Playgroud)
看来您的问题出在 Maven 存储库设置中。将下面的代码放入位于项目核心文件夹中的build.gradle中。
buildscript {
repositories {
mavenCentral()
google()
}}
Run Code Online (Sandbox Code Playgroud)
如果它没有帮助或者该存储库已经存在 - 尝试关闭离线模式。进入 Preferences > Gradle 并取消选中“Offline work” 如果 Gradle 处于离线模式,这意味着它不会去网络来解决依赖关系。
| 归档时间: |
|
| 查看次数: |
16294 次 |
| 最近记录: |