错误:无法解析':app @ debugAndroidTest/compileClasspath'的依赖项:无法解析junit:junit:4.12
gradle (2)
在build.gradle文件中添加以下存储库,
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
你忘了把它添加到你的依赖项中
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
问题是由espresso库引起的,如果你无法将其删除,请将其添加到你的应用程序gradle中
android
{
configurations.all
{
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
我创建了一个新的android项目它显示了构建的错误
我尝试了现有的答案
- 无法解决:com.android.support:appcompat-v7 24.0.1
- 我试图使无效并重新启动android studio
错误是
错误:无法解析':app @ debugAndroidTest / compileClasspath'的依赖项:无法解析junit:junit:4.12。
错误:无法解析':app @ releaseUnitTest / compileClasspath'的依赖项:无法解析junit:junit:4.12。
错误:无法解析':app @ debugUnitTest / compileClasspath'的依赖关系:无法解析junit:junit:4.12。
错误:无法解析':app @ debugAndroidTest / compileClasspath'的依赖项:无法解析com.google.code.findbugs:jsr305:2.0.1。
我的gradle文件的依赖项部分
dependencies
{
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
}
我不明白这是我的第一个项目。
我的Project gradle是
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的应用程序是gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
android
{
configurations.all
{
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies
{
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
}
我试图混合AppCompat和Jetpack依赖项,你不能这样做。
我想我可能没有为Jetpack库设置正确的存储库(为什么它找不到任何Jetpack库)。
不要使用:实现'androidx.appcompat:appcompat:1.0.2'。 (这是Jetpack) - 使用它的AppCompat版本(此外 - Jetpack与28.x之前的Appcompat版本不一致)。 最重要的是,摆脱任何说(androidx)。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
}