[英]How to resolve DependencyResolutionManagement warning in Kotlin DSL
I created a new Android project using Android Studio version - Electric Eel .我使用 Android Studio 版本 - Electric Eel创建了一个新的 Android 项目。 And I was trying to migrate gradle scripts from
groovy
to kotlin DSL
, met warnings.我试图将 gradle 脚本从
groovy
迁移到kotlin DSL
,遇到警告。
In last project developed on previous version of Android Studio - Chipmunk , script was clean.在之前版本的 Android Studio - Chipmunk上开发的最后一个项目中,脚本是干净的。 The scripts between last project and new project are equal.
上一个项目和新项目之间的脚本是相等的。
I want to remove the warning message in the right way not supressing them.我想以正确的方式删除警告消息而不是压制它们。 I know what the annotation(
@Incubating
) means.我知道注释(
@Incubating
)是什么意思。
Here's the settings.gradle.kts
.这是
settings.gradle.kts
。
Comments are the warnings I encountered.评论是我遇到的警告。
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
// 'getRepositoriesMode()' is declared in unstable interface 'org.gradle.api.initialization.resolve.DependencyResolutionManagement' marked with @Incubating
// 'org.gradle.api.initialization.resolve.RepositoriesMode' is marked unstable with @Incubating
// 'FAIL_ON_PROJECT_REPOS' is declared in unstable enum 'org.gradle.api.initialization.resolve.RepositoriesMode' marked with @Incubating
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
// 'repositories(org.gradle.api.Action<? super org.gradle.api.artifacts.dsl.RepositoryHandler>)' is declared in unstable interface 'org.gradle.api.initialization.resolve.DependencyResolutionManagement' marked with @Incubating
repositories {
google()
mavenCentral()
}
}
rootProject.name = "MyNewProject"
include(":app")
My IDE, gradle, agp versions:我的 IDE、gradle、agp 版本:
Android Studio Electric Eel |
Android 工作室电鳗 | 2022.1.1
2022.1.1
Build #AI-221.6008.13.2211.9477386, built on January 11, 2023Build #AI-221.6008.13.2211.9477386,建于 2023 年 1 月 11 日
Runtime version: 11.0.16+8-b2043.64 amd64运行时版本:11.0.16+8-b2043.64 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.VM:JetBrains s.r.o 的 OpenJDK 64 位服务器 VM。
Windows 10 10.0Windows 10 10.0
GC: G1 Young Generation, G1 Old GenerationGC:G1年轻代,G1老年代
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
(in build.gradle
, which is still with groovy
) (在
build.gradle
中,仍然与groovy
)
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
I double checked the Inspection settings both IDE versions, Unstable API Usage options are all enabled.我仔细检查了两个 IDE 版本的检查设置,不稳定的 API 使用选项都已启用。 The options includes correct annotation -
org.gradle.api.incubating
.选项包括正确的注释 -
org.gradle.api.incubating
。
I think electric eel version resolves a bug(Actucally I'm not sure), but this is not resolved clearly, until they release it stable API or other way...我认为电鳗版本解决了一个错误(实际上我不确定),但这并没有明确解决,直到他们发布稳定版 API 或其他方式......
For now I added @file:Suppress("UnstableApiUsage")
at the top of each gradle script.现在我在每个 gradle 脚本的顶部添加了
@file:Suppress("UnstableApiUsage")
。
Add @Suppress("UnstableApiUsage") to fix temporarily problem in the interested code like添加 @Suppress("UnstableApiUsage") 以暂时修复感兴趣的代码中的问题,例如
@Suppress("UnstableApiUsage")
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.