Gradle sync Failed and many error are appearing as could not resolve

Refresh

April 2019

Views

187 time

1

I am not able to understand what is the issue? Can anyone Help, attaching the screenshot for Android Studio

Build grade file is // 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:3.0.1'


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

My app build.gradle file is

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.a479729.myapplication"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

Image

2 answers

0

It seems problem is in your gradle version. Most of the time this error happen when you import others project. Because it can have old gradle scripts than your version. To upgrade your gradle, Delete those gradle files in project . Then clean & rebuild your project. Then android studio ask to download new gradle version from internet. Wait until download is complete. It will solve errors in gradle.

0

Try this, In your top level build gradle

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

ref: https://developer.android.com/topic/libraries/support-library/setup.html