Tag Archives: Build error

Build failed for Android studio new project

Build failed for Android studio new project

Error information

org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'Test1'.

Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'Test1'

Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'Test1'

##The solution
is to build.gradle The buildscript and allprojects in are changed to the following configuration

this is the original configuration

Change to the following code:

buildscript {

    repositories {
        // maven
        def cn = "http://maven.aliyun.com/nexus/content/groups/public/"
        def abroad = "http://central.maven.org/maven2/"
        // First download the jar from the url if not found, then look in the artifactUrls
        maven {
            url cn
            artifactUrls abroad
        }
        maven { url "http://maven.aliyun.com/nexus/content/repositories/jcenter"}
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        // maven
        def cn = "http://maven.aliyun.com/nexus/content/groups/public/"
        def abroad = "http://central.maven.org/maven2/"
        // First download the jar from the url if not found, then look in the artifactUrls
        maven {
            url cn
            artifactUrls abroad
        }
        maven { url "http://maven.aliyun.com/nexus/content/repositories/jcenter"}
        google()
    }
}