当前位置: 首页 > 知识库问答 >
问题:

在 Android 工作室北极狐金丝雀 8 中,应用关卡 build.gradle 不会生成“所有项目”部分,并且在手动添加时会导致错误

冯皓
2023-03-14

在 Android 工作室北极狐金丝雀 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
}

我正在使用的库之一需要allproject

我手动尝试在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'

为什么Android Studio Canary 8中的allproject被删除,如何将其添加回来以便我可以使用库?

共有3个答案

汪高岑
2023-03-14

转到< code>setting.gradle并替换该行:

repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

使用:

repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)

这是一个梯度设置,允许这个工作。

谭文林
2023-03-14

在<code>设置中。gradle只需注释掉整个块

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}
曹自怡
2023-03-14

在<code>设置中。gradle您可以添加要添加到项目中的存储库

dependencyResolutionManagement {
   repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
   repositories {
      google()
      mavenCentral()
      jcenter()
      maven { url "https://maven.xyz.com" }
    }
}
 类似资料:
  • 嗨,我正在尝试在VSTS上配置一个连续部署构建,但我似乎无法使构建工作。我还应该提到,我一周前才开始学习VSTS,所以我可能会错过一些非常明显的东西。以下是我迄今为止所做的工作: 我已使用以下配置创建了Visual Studio生成步骤: < li >解决方案:$/commerci fy/Dev/commerci fy . SLN < li>MSBuild参数: /p:DeployOnBuild=

  • 问题内容: 示例代码: 在代码中,我已经执行了一些无效的读取和无效的写入,但是这个小程序可以正常工作,并且不会创建。 但是一旦进入我的大库,每当我进行1个字节的无效读取或无效写入时,它总是在创建核心转储。 题: 为什么有时我会通过无效的读/写操作获得核心转储,而有时却没有获得核心转储? 问题答案: 您想要做的基本上是缓冲区溢出&在您的代码示例中,更具体地说是堆溢出。您有时只看到崩溃的原因取决于您正

  • [颤振]flutter.bat医生-v[√]颤振(通道稳定,v1.12.13热修复补丁.9,在微软视窗[版本10.0.18363.778],区域设置en-GB)颤振版本1.12.13热修复补丁.9在D:\flutter\flutter框架修订f139b11009(5周前),2020-03-30 13:57:30-0700引擎修订af51afceb8 Dart版本2.7.2 [!]Android工具

  • 我有一个示例项目,设置如下: 其中“测试项目”依赖于“测试库”,而最后一个依赖于“纯Java库”,编译该项目并启动此设置工作正常。 我现在正在考虑导入以前的Eclipse工作区,并与Android studio一起工作,问题是项目设置不同,我希望保持这种方式。 我尝试了很多配置,但没有找到一种方法来引用父文件夹范围之外的项目(在示例中为'root')。 在许多平台/模块中,您可以使用“..”但这对

  • 我正在尝试构建一个新创建的Xamarin。Android平台的表单应用程序。关于@drawable文件的丢失,我遇到了各种各样的错误(目前有73个)。 如果我从Resources/drawable文件夹中删除特定的PNG文件,错误就会消失。这是我用来作为页面背景的图像。目前它只有515KB,大小为500x750。该资源有一个AndroidResource的构建操作,就像我包含的另一个PNG文件一样