Ajay Maurya
Ajay Maurya

Reputation: 611

Gradle sync error in android studio 3.0.1 with gradle build 4.1

Below is the screenshot of the error, Any help will really be appreciated.

This error pops up every time I load a new project or either create a one, Thi error is bugging me for 2 weeks any help will really be appreciated.

Upvotes: 0

Views: 1326

Answers (2)

Nikhil Dikshit
Nikhil Dikshit

Reputation: 11

There are several errors which you can encounter on installing the AS 3.0.1. Most common of which are -

Error 1 Error: Failed to find Build Tools revision 26.0.2 “install.build.tools” Install Build Tools 26.0.2 and sync project.

Solution: In build.gradle file update the configuration because right now it is looking for API 26. If you check in the SDK Manager, it shows that you actually have version 27. So, there is no need to install the SDK of API level 26, rather update the configuration in build.gradle file as follows":

=> Change the compileSdkVersion from 26 to 27 and change the targetSdkVersion from 26 to 27.

Error 2 Error:Failed to find Build Tools revision 26.0.2 "install.build.tools" Install Build Tools 26.0.2 and sync project.

Solution: In the same (build.gradle) file, add buildToolsVersion "27.0.3" just below compileSdkVersion 27. The code must somewhat appear like:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.example.android.happybirthday"
        minSdkVersion 15
        targetSdkVersion 27
        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'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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'
}

After these changes the studio should work fine and you'll be able to begin your development. One more way to verify the same is that you must now see an 'Android' submenu under 'Tools' in the menubar.

Upvotes: 1

ZarNi Myo Sett Win
ZarNi Myo Sett Win

Reputation: 1453

Firstly, go to "C:\Users{user_name}\", you will find folder .gradle. Delete it and go back to your Android Studio and click the menu Build>Clean Project or Build>Rebuild Project. Note, you must have Internet connection.

Upvotes: 0

Related Questions