1

While generating APK, It's showing build failed, this is the error message :

    Could not find com.android.tools.lint:lint-gradle:26.1.1.
Searched in the following locations:
    file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
    file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
    file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
    file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
    file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
    file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
    https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
    https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
Required by:
    project :app

this is build gradl file (app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "appli.myapp.app"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:23.0.0'
    implementation 'com.google.android.gms:play-services:8.4.0'
}

this is a build gradle (project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I am a beginner on android studio :/, I made several times "clean" but it does not work unfortunately Help me please Thank you

Alex Bene
  • 233
  • 2
  • 3
  • 10
  • this is a build gradle (project) // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } – Alex Bene Apr 29 '18 at 17:17
  • Could you edit your question and add the code snipped you posted in the comment into the question itself and correctly formatted so it's easier to read. – Jude Fernandes Apr 29 '18 at 17:21
  • @JudeFernandes I have this error :/ It looks like your post is mostly code; please add some more details. – Alex Bene Apr 29 '18 at 17:30
  • Just add a little more text to describe your situation and stackoverflow should let you through. – Jude Fernandes Apr 29 '18 at 17:35
  • @JudeFernandes ok friend, thank you, it worked – Alex Bene Apr 29 '18 at 18:07

2 Answers2

1

First try disabling AS offline mode

Go to File -> Settings.

And open the 'Build,Execution,Deployment',Then open the 'Build Tools' -> 'Gradle'.

Then uncheck "Offline work" on the right.

Click the 'OK' button.

Then Rebuild the Project.

For Mac go to AndroidStudio -> Preferences, rest is same.

If this does not work then try this. According to this reference question

Per the Android Studio docs , your top-level build.gradle ought to have the google() repository added. Be sure to add it to the repositories under buildscript AND allprojects.

The latter one is what I missed the first time I edited this today after upgrading and that led directly to a Could not find com.android.tools.lint:lint-gradle:26.1.1. when I tried to build a release APK.

Add the google() in your project level build.gradle like this

buildscript {
    repositories {
        jcenter()
        google()
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}
Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
0

Seems like you might be missing a few sdk files, goto the sdk manager and update to latest versions and upgrade your appcompat versions to 27.1.1, update your target sdk to 27 as well as compile sdk and use classpath 'com.android.tools.build:gradle:3.1.2' for that you will also need to use this in your gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Jude Fernandes
  • 7,437
  • 11
  • 53
  • 90