我试着使用老师给我的一个项目,但是它显示了一个错误
Settings file '/Users/admin/AndroidStudioProjects/HTTPNetworking/settings.gradle' line: 1
A problem occurred evaluating settings 'HTTPNetworking'.
> Could not find method dependencyResolutionManagement() for arguments [settings_d1xerae4a210x6r7efckrwyki$_run_closure1@580a3803] on settings 'HTTPNetworking' of type org.gradle.initialization.DefaultSettings.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating settings 'HTTPNetworking'.
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method dependencyResolutionManagement() for arguments [settings_d1xerae4a210x6r7efckrwyki$_run_closure1@580a3803] on settings 'HTTPNetworking' of type org.gradle.initialization.DefaultSettings
at settings_d1xerae4a210x6r7efckrwyki.run(/Users/admin/AndroidStudioProjects/HTTPNetworking/settings.gradle:1)
设置。gradle包含:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "HTTP Networking"
include ':app'
有什么问题吗?
4条答案
按热度按时间kdfy810k1#
在
gradle-7.3
和较低的方法dependencyResolutionManagement
中有@Incubating
注解。要在您的settings.gradle
或settings.gradle.kts
文件中使用此方法,您需要添加行:0kjbasz62#
此错误可能是由于在
build.gradle
文件中定义dependencyResolutionManagement
块而不是在**settings.gradle
**(doco明确告诉您放置它的位置)中定义dependencyResolutionManagement
块而导致的。不是说 * 我 * 做了什么。如果你也完全没有犯那个明显愚蠢的错误,请自由地投票给这个答案。
dddzy1tm3#
此错误可能是由于使用了较旧的gradle版本而导致的,在我将我的项目的gradle版本升级到7.4.2后,问题得到了解决
tuwxkamq4#
复制并替换
Top-level build file
中的以下代码:并在settings中对这些行进行注解。gardle(:):
请注意,
Gradle Version
最好为6.6,因为Gradle Plugin
4.1.3