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

R. Ranjan
  • 11
  • 2
  • 1
    post your build.gradle file – Munir Dec 27 '17 at 08:02
  • i have attached the screenshot – R. Ranjan Dec 27 '17 at 08:04
  • // 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 } – R. Ranjan Dec 27 '17 at 08:04
  • not top level gradle post app build.gradle. – Munir Dec 27 '17 at 08:05
  • not that's one, post app level gradle file where all dependency written. find it out at app folder – Munir Dec 27 '17 at 08:17
  • posted the app level grade file – R. Ranjan Dec 27 '17 at 08:27

2 Answers2

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

Raghavendra
  • 2,305
  • 25
  • 30
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.

Dinith Rukshan Kumara
  • 638
  • 2
  • 10
  • 19
  • i think this is the latest gradle there, not the old one, i have downloaded everything today only and i started for the first time, so no old scripts – R. Ranjan Dec 27 '17 at 08:26
  • Ok. Then problem is not because of your version. Problem can be in gradle metadata and data. invalidate caches & rebuil your project. Goto File -> Invalidate caches / Restart Shutdown Android Studio Rename/remove .gradle folder in the user home directory Restart Android Studio (It will download gradle metadata and data) – Dinith Rukshan Kumara Dec 27 '17 at 08:34
  • Done. but the issue is still there – R. Ranjan Dec 27 '17 at 09:15
  • Oh.. its sad. Then create a new project. If its build fail, uninstall android studio & reinstall it. If project build success, Copy & paste your java files, layouts & other data to new project, except gradle files. That is the easiest way other than removing that error. – Dinith Rukshan Kumara Dec 27 '17 at 11:49