解决方法主要有两种,一种是升级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是同级的
再编译就通过啦!
网友评论