Android studio报错Could not find method dependencyResolutionManagement()的解决办法

2,762 阅读1分钟

一、Android Gradle Plugin Version版本太高 用新的Android studio版本“北极狐”新建项目,Gradle版本直接最新的,编译的时候提示Java版本不对,进File-Project Structure改一下Gradle Plugin Version。我的设置是这样:

image.png

二、Could not find method dependencyResolutionManagement() for arguments 这个错误一般都是配置有问题,我解决的方法是把外面的build.gradle里的内容改为:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.3"

        // 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
}

再把settings.gradle里的多余的删了,只留下:

include ':app'
rootProject.name = "AppName"

进行完上述操作,再编译程序运行通过了!