当前位置: 首页 > 知识库问答 >
问题:

无法解决':app@debugUnitTest /compileClasspath'的依赖关系

诸葛利
2023-03-14

当我尝试添加新项目并修改我的gradle(添加依赖项)时,我在同步gradle后收到了这条消息:

无法解析“”的依赖项:app@debugAndroidTest/compileClasspath“:无法下载kotlin-stdlib-1.4.31.jar(org.jetbrains.kotlin:kotlin stdlib:1.4.31)

显示详细信息

受影响的模块:应用程序

我无法单击“显示详细信息”链接

Gradle项目

buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Gradle应用程序

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 19
        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'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.5.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}

共有1个答案

马银龙
2023-03-14

尝试将您的第二个依赖项替换为:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
 类似资料: