Solution to Android studio error Could not find method dependencyResolutionManagement() for arguments

Recently, I helped a colleague install Android studio. After the installation, I tried to create a new project. As a result, the newly created Hello World couldn't run. Here I will record the problems encountered and the solutions.
1. The Android Gradle Plugin Version is too high.
Use the new Android studio version "Arctic Fox" to create a new project. The Gradle version is directly the latest. When compiling, it prompts that the Java version is incorrect. Go to File-Project Structure and change the Gradle Plugin Version. My settings are as follows:
insert image description here
2. Could not find method dependencyResolutionManagement() for arguments
This error is generally a configuration problem. My solution is to change the content in the external build.gradle to:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
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
}

Then delete the redundant one in settings.gradle, leaving only:

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

After performing the above operations, compile the program and run it!

It is really too difficult for new projects to run.

Guess you like

Origin blog.csdn.net/qq_35761934/article/details/121248724