我有一个android项目,它以前运行良好。
今天我将Android Studio升级到Arctic Fox 2020.3.1,然后在Android Studio Arctic Fox 2020.3.1中运行项目,但出现以下错误。
我调试项目,我认为代码mavenCentral()
导致错误,所以我替换 mavenCentral()
为jcenter()
,应用程序可以正常工作。
我知道那jcenter()
已经过时了,但为什么会mavenCentral()
导致错误?
错误
**Execution failed for task ':app:kaptGenerateStubsFreeDebugMiniKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Failed to transform kotlinx-metadata-jvm-0.2.0.jar (org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.2.0) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download kotlinx-metadata-jvm-0.2.0.jar (org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.2.0)
> Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-metadata-jvm/0.2.0/kotlinx-metadata-jvm-0.2.0.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-metadata-jvm/0.2.0/kotlinx-metadata-jvm-0.2.0.jar'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/127.0.0.1] failed: Connection refused: connect
> Failed to transform annotations-12.0.jar (com.intellij:annotations:12.0) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download annotations-12.0.jar (com.intellij:annotations:12.0)
> Could not get resource 'https://repo.maven.apache.org/maven2/com/intellij/annotations/12.0/annotations-12.0.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/com/intellij/annotations/12.0/annotations-12.0.jar'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/127.0.0.1] failed: Connection refused: connect
> Failed to transform guava-29.0-jre.jar (com.google.guava:guava:29.0-jre) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download guava-29.0-jre.jar (com.google.guava:guava:29.0-jre)
> Could not get resource 'https://repo.maven.apache.org/maven2/com/google/guava/guava/29.0-jre/guava-29.0-jre.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/com/google/guava/guava/29.0-jre/guava-29.0-jre.jar'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/127.0.0.1] failed: Connection refused: connect
> Failed to transform checker-qual-2.11.1.jar (org.checkerframework:checker-qual:2.11.1) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download checker-qual-2.11.1.jar (org.checkerframework:checker-qual:2.11.1)
> Could not get resource 'https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/2.11.1/checker-qual-2.11.1.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/2.11.1/checker-qual-2.11.1.jar'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/127.0.0.1] failed: Connection refused: connect
> Failed to transform error_prone_annotations-2.3.4.jar (com.google.errorprone:error_prone_annotations:2.3.4) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download error_prone_annotations-2.3.4.jar (com.google.errorprone:error_prone_annotations:2.3.4)
> Could not get resource 'https://repo.maven.apache.org/maven2/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/127.0.0.1] failed: Connection refused: connect**
*** 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.**
构建.gradle
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
jcenter()
//mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
}
}
allprojects {
repositories {
google()
jcenter()
//mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}