Android Studio 的项目 gradle 文件中的更改



我最近更新了我的Android Studio到最新版本。但是这里的gradle文件似乎有点不同。

下面是gradle代码:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}

我想在项目gradle文件中添加下面的jitsi行。我应该如何粘贴它,使它正确地同步而没有任何错误。

这里是jitsi代码:

allprojects {
repositories {
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
google()
mavenCentral()
maven { url 'https://www.jitpack.io' }
}
}

我已经尝试通过添加或替换上面的行来改变gradle文件,没有任何变化。抛出一个错误。

当您使用最近修订的构建配置脚本时,您应该能够在settings.gradle文件下声明您的存储库:

pluginManagement {
// Plugin repositories go here
}
// ...
dependencyResolutionManagement {
/**
* The dependencyResolutionManagement {repositories {...}}
* block is where you configure the repositories and dependencies used by
* all modules in your project, such as libraries that you are using to
* create your application. However, you should configure module-specific
* dependencies in each module-level build.gradle file. For new projects,
* Android Studio includes Google's Maven repository and the Maven Central
* Repository by default, but it does not configure any dependencies (unless
* you select a template that requires some).
*/
// The following line makes it so that project modules (such as your
// "app" module) can't declare their own repositories {} block
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Add your repositories here...
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
maven { url 'https://www.jitpack.io' }
}
}

只允许buildscript {}, pluginManagement{}和其他插件{}脚本块在插件{}块之前,不允许其他语句

对于这个错误,这是因为plugins块总是先解析,所以任何其他代码必须在块之后声明:
// There shouldn't be any code before this!
plugins {
}
// Okay to have build script code here...

Android studio最新版本你在项目的设置中移动jitsi库。gradle文件

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
mavenLocal()
}
}

最新更新