Alex Bene
Alex Bene

Reputation: 243

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

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

Upvotes: 1

Views: 475

Answers (2)

Jude Fernandes
Jude Fernandes

Reputation: 7517

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

Upvotes: 0

Khemraj Sharma
Khemraj Sharma

Reputation: 59004

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()
    }
}

Upvotes: 1

Related Questions