Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了错误:无法解析“:app @ debugAndroidTest / compileClasspath”的依赖项:无法解析junit:junit:4.12 大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我创建了一个新的android项目,它在构建时显示错误@H_489_2@

我尝试了现有的答案@H_489_2@

> Failed to resolve: com.android.support:appcompat-v7 24.0.1
>我试图使Android studio无效并重新启动@H_489_2@

错误是@H_489_2@

我的gradle文件的依赖项部分@H_489_2@

 dependencies 
    {
       implementation 'androidx.appcompat:appcompat:1.0.2'
    testImplementation 'junit:junit:4.12'

    }

我不明白这是我的第一个项目.@H_489_2@

我的项目gradle是@H_489_2@

// 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是@H_489_2@

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'


}
最佳答案
在build.gradle文件添加以下存储库,

repositories {
      jcenter()
      maven {
        url 'https://maven.google.com'
    }
}

您忘了将此添加到您的依赖项@H_489_2@

androidTESTCompile 'com.google.code.findbugs:jsr305:3.0.0' 

问题是由espresso库引起的,如果您无法删除它,请将其添加到应用程序gradle中@H_489_2@

android
{ 
 configurations.all 
  { 
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' 
  }
}

大佬总结

以上是大佬教程为你收集整理的错误:无法解析“:app @ debugAndroidTest / compileClasspath”的依赖项:无法解析junit:junit:4.12 全部内容,希望文章能够帮你解决错误:无法解析“:app @ debugAndroidTest / compileClasspath”的依赖项:无法解析junit:junit:4.12 所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。