首页 > 解决方案 > 错误重复“无法解析配置':app:debugRuntimeClasspath'的所有文件'

问题描述

当我尝试运行这个基本应用程序时,我得到“无法解析配置':app:debugRuntimeClasspath'的所有文件”。

gradle.build(应用程序)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-parcelize'


android {
    compileSdkVersion 31
    defaultConfig {
        applicationId "hellokotlinandroid.gohool.com.buttonstextviewedittext"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7"
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.13.2'

}

gradle.build(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.5.31'
    repositories {
        maven { url 'https://maven.google.com' }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        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
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.6.0-RC'
}
repositories {
    mavenCentral()
    google()
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

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

这是完整的错误

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.6.0-RC.
     Searched in the following locations:
       - https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.6.0-RC/kotlin-stdlib-jre7-1.6.0-RC.pom
       - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.6.0-RC/kotlin-stdlib-jre7-1.6.0-RC.pom
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.6.0-RC/kotlin-stdlib-jre7-1.6.0-RC.pom
     Required by:
         project :app

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

此错误重复多次,准确地说是 17 次,是同一件事,但每次的任务略有不同

我已经浏览了论坛并尝试了他们所说的但似乎找不到任何东西并尝试了所有基本的故障排除任何建议表示赞赏,谢谢!

标签: androidandroid-studiokotlinerror-handling

解决方案


有同样的问题,就我而言,我做了以下这些

kotlinOptions { jvmTarget = "1.8" }

change to  

kotlinOptions { jvmTarget = "11" }

基本上从 jdk 1.8 更改为 11。或者通过Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JDK (change to 11 or Embedded JDK)

清理项目和重建项目。


推荐阅读