android - 在Android Studio Arctic Fox Canary 8中,app级build.gradle不生成`allprojects`部分,手动添加时会报错
问题描述
在 Android Studio 北极狐金丝雀 8 中创建新项目时,这是应用级别的 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha08"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在 Android Studio 4.1.2 中创建相同的新项目时,应用级 build.gradle 文件是这样的:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
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
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我正在使用的库之一需要allprojects
我手动尝试allprojects
在 Canary 8 中添加该部分,收到此错误:
problem occurred evaluating root project 'My Application'.
> Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'
为什么allprojects
Android Studio Canary 8 中的 被删除了,我怎样才能将它添加回来以便我可以使用这些库?
解决方案
您可以在settings.gradle
其中添加要添加到项目的存储库
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://maven.xyz.com" }
}
}
推荐阅读
- java - 用于文本分析的 Elasticsearch 分析器
- sql-server - 来自同一个表的多个插入,但第二个插入需要来自第一个插入的标识
- javascript - 从 Nodejs express 应用程序发布到 MySQL 数据库返回 404
- laravel - 在 Dusk 测试中,日期字段始终采用美国格式
- c++ - 什么时候可以在 C++ 中意外更改变量的值?
- reactjs - 与 Gatsby 和 Bulma 反应 - 列不水平
- xamarin.forms - 将 TextField 绑定到 Xamarin.Forms 中的 Int 属性
- pandas - 如何查找列连续月数为 6 的索引?
- html - 位置:修复了 Safari 与 Chrome 处理方式不同的问题
- javascript - 旋转时将元素指向圆心(CSS / JS)