首先需要知道的是:
1.连接错误的原因是因为没有正确上网导致的maven相关的资源拉不下来,没有梯子,就使用国内的开源网址
2. gradle插件版本号在7.0之后,build.gradle和settings.gradle配置容易重复,导致报错:
Build was configured to prefer settings repositories over project repositori…
解决方案
1.把settings.gradle的dependencyResolutionManagement整体注释,settings.gradle完整代码:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
//dependencyResolutionManagement {
// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
// repositories {
// google()
mavenCentral()
// maven {
// url 'https://maven.aliyun.com/repository/central/'
// }
// }
//}
rootProject.name = "xxx"
include ':app'
include ':aidlaar'
2.在build.gradle中添加别的开源网址,完整代码:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter() // Warning: this repository is going to shut down soon
//添加各种源
maven {
url 'https://maven.aliyun.com/repository/central/'
}
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven {
url "https://jitpack.io"
}
maven {
url "https://dl.bintray.com/lukaville/maven"
}
maven {
url "https://maven.google.com/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}