解决使用7.0.0以上版本的Gradle version和Gradle Plugin version构建Kotlin项目拉取在4.1.1版本的Android Studio编译会出现的问题

解决方法主要有两种,一种是升级Android Studio到雪狐版本,然后安装Java 11,对就是要Java11才支持。

另一种是把项目Gradle Version调低,比如:Gradle Version:6.5、Gradle Plugin version:4.1.1

然后编译会报以下错误:

A problem occurred evaluating settings 'PackerQuickDevelop'.
> Could not find method dependencyResolutionManagement() for arguments [settings_3j3hkhbl8g4ki6b0h7rhxmftv$_run_closure1@10e89934] on settings 'PackerQuickDevelop' of type org.gradle.initialization.DefaultSettings.

这个时候需要在settings.gradle把以下内容注释:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

再编译再报错,

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21 because no repositories are defined.

然后,再项目模块外的build.gradle,添加以下内容:

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}
//注意,allprojects和buildscript是同级的

再编译就通过啦!

你可能感兴趣的:(解决使用7.0.0以上版本的Gradle version和Gradle Plugin version构建Kotlin项目拉取在4.1.1版本的Android Studio编译会出现的问题)