Could not find com.android.tools.lint:lint-gradle Android Studio 3
Asked Answered
C

15

103

I have updated Android Studio to 3.0 and now received a lot of issues.. now stoped on point with such issue:

Could not resolve all files for configuration ':applib:_lintClassPath'.
> Could not find com.android.tools.lint:lint-gradle:26.1.0-alpha01.
  Searched in the following locations:
      file:/Users/anwender/Library/Android/sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.pom
      file:/Users/anwender/Library/Android/sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.jar
      file:/Users/anwender/Library/Android/sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.pom
      file:/Users/anwender/Library/Android/sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.jar
      file:/Users/anwender/Library/Android/sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.pom
      file:/Users/anwender/Library/Android/sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.jar
      https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.pom
      https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.jar
      https://jitpack.io/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.pom
      https://jitpack.io/com/android/tools/lint/lint-gradle/26.1.0-alpha01/lint-gradle-26.1.0-alpha01.jar
      file:/Users/anwender/dev/project/dk_shopping_checklist/augmented/libs/lint-gradle-26.1.0-alpha01.jar
      file:/Users/anwender/dev/project/dk_shopping_checklist/augmented/libs/lint-gradle.jar
  Required by:
      project :applib

Does someone know what the issue can be?

Gradle.build:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 26
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:+'
}

I'm using latest gradle version: "gradle-4.2.1-all.zip".

Crossley answered 27/10, 2017 at 9:45 Comment(1)
I downgrade my gradle class path from 3.1.4 to 3.1.0 And problem solvedSicanian
M
60

It looks to me like you're missing the google() repository in order to fetch the dependency.

Here's the link to the pom file that you're looking for: https://dl.google.com/dl/android/maven2/com/android/tools/testutils/26.1.0-alpha01/testutils-26.1.0-alpha01.pom

Multifaceted answered 5/11, 2017 at 23:6 Comment(4)
Thanks. Solved. Also added "classpath "com.android.tools.build:gradle:$gradle_version" in current .gradle, instead of global.Crossley
It's worth mentioning that this should be included in each projects' build.gradle file, not just the root as required in previous gradle versionsTerbia
I was getting this error: project : > com.android.tools.lint:lint-gradle:26.1.4 - whether same file will work for me?Vernice
For me, I had that line added, but it wasn't in the first line. google() must be the first repo of all. This did the trick for meDigenesis
H
191

If you're running lint on a project that you created using an older version of Android Studio, you may encounter this error.

To resolve this issue, for each project that you would like to run lint on, include Google's Maven repository in the top-level build.gradle file, as shown below:

allprojects {
    repositories {
        // The order in which you list these repositories matter.
        google()
        jcenter()
    }
}
Heated answered 25/1, 2018 at 8:47 Comment(5)
It was the ordering mentioned in this comment that really fixed it for me.Osteomyelitis
google() repository needs to be added if not already added. It wasn't added for me.Higa
Couple this solution by also running ./gradlew clean build --refresh-dependencies to force Gradle to update dependenciesUrsulina
That was not enough in my case, actually. I also added lintOptions { abortOnError false }, to break "recursion". The explanation was that, Lint fails because of missing dependencies, then will abort, but the missing dependencies would be downloaded, if lint weren't to abort the build when it hits the error. I removed the entry afterwards, and everything was fine from that point on.Sentiment
For me it was the allprojects part that finally solved the problem. Initially I just pasted the same code into a buildscript section.Intercurrent
M
60

It looks to me like you're missing the google() repository in order to fetch the dependency.

Here's the link to the pom file that you're looking for: https://dl.google.com/dl/android/maven2/com/android/tools/testutils/26.1.0-alpha01/testutils-26.1.0-alpha01.pom

Multifaceted answered 5/11, 2017 at 23:6 Comment(4)
Thanks. Solved. Also added "classpath "com.android.tools.build:gradle:$gradle_version" in current .gradle, instead of global.Crossley
It's worth mentioning that this should be included in each projects' build.gradle file, not just the root as required in previous gradle versionsTerbia
I was getting this error: project : > com.android.tools.lint:lint-gradle:26.1.4 - whether same file will work for me?Vernice
For me, I had that line added, but it wasn't in the first line. google() must be the first repo of all. This did the trick for meDigenesis
T
26

My answer is for everyone that Already have google() in repositories but still have same error

  1. goto android studio settings and search for "HTTP Proxy" and make sure you haven't set a wrong proxy there. (set it to auto-detect proxy settings if not sure)
  2. close android studio
  3. goto C:/Users/DESKTOP-NAME/ and Delete .gradle folder (yes, it's big folder but don't be scared its just keeping all versions of your old gradle files that is not needed now)
  4. goto you project folder and delete .gradle folder and app/build folder (make a backup before this just in case)
  5. restart your PROXY server Or VPN provider (if you use one) and make sure you have a working internet connection.
  6. Open Android Studio and wait until successful build (it's gonna take a little longer).
Titre answered 21/7, 2020 at 14:11 Comment(2)
I'm leaving this for posterity, one of the best ways to suffer is developing Android Apps in Iran due to harsh sanctions by the USA.Electrophoresis
I deleted the .gradle folder in the %UserProfile%, and the issue was resolved.Vise
P
9

I solved this by adding the https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api repo to build.gradle:

repositories {
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    jcenter()
    maven {
        url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api'
    }
}
Performance answered 7/11, 2018 at 19:40 Comment(0)
F
2

just comment google and sync project

   repositories {
    google()
    jcenter()
   }

Disable offline mode and uncomment google() and sync again...

Faught answered 14/6, 2020 at 18:30 Comment(0)
F
2

To solve dependencies issues it's always helpful to use

./gradlew clean build --refresh-dependencies

In my case I got the next message:

- Variant 'runtimeElements' capability com.android.tools.lint:lint-api:30.0.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
          - Incompatible because this component declares a component compatible with Java 8 and the consumer needed a component compatible with Java 7
          - Other compatible attribute:
              - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)

So, my problem with this dependency was that I was using:

java {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
}

and this particular dependency requires JavaVersion.VERSION_1_8 instead. When I replaced it by

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

it started working.

Further answered 6/10, 2021 at 16:43 Comment(0)
C
1

I have changed my current gradle version(3.3.2 to 3.2.1) from the global build.gradle file.

buildscript {
 repositories {
    google()
    jcenter()
    maven { url 'https://maven.google.com' }
 }

 dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
 }
}

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

then click on sync gradle button on the top right corner of the screen.

Coheir answered 1/6, 2019 at 6:2 Comment(1)
This worked for me, but this answer didn't get me there. I found this answer to have a better explanation: stackoverflow.com/a/67738543Gomer
A
1

Try this,

File -> Settings -> Build,Execution,Deployment -> Gradle -> Android Studio -> Select -Enable embedded maven repository - Apply.

Afro answered 22/8, 2019 at 5:55 Comment(1)
I know this was posted long time age but the problem is still there, This is the only solution that work for me.Obsession
M
1

Another option is

./gradlew -x:app:lintVitalRelease assemble

To quote Gradle Docs:

Excluding tasks from execution

You can exclude a task from being executed using the -x or --exclude-task command-line option and providing the name of the task to exclude.

Reference: https://docs.gradle.org/current/userguide/command_line_interface.html#sec:excluding_tasks_from_the_command_line

Archived link: http://archive.is/TsPPJ#sec:excluding_tasks_from_the_command_line

Maintenon answered 13/1, 2020 at 12:1 Comment(0)
D
0

Add google() to your gradle If you face this again,Do not add a linter disabler to your gradle, This is an access error issue,I faced that on react-native after using sudo command for a few command, Just reset your code access and then release again For example the mac

sudo chmod -R 777 <project-root-folder-name>

Delve answered 19/7, 2019 at 16:21 Comment(0)
H
0

add below code to your build.gradle (Module) to skip error

lintOptions {
        abortOnError false
}
Highbinder answered 8/8, 2019 at 5:29 Comment(0)
F
0

My has this issue, solved by below lines

buildscript {
ext.kotlin_version = '1.3.60'

repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1' //3.4.2, 3.4.1^, 2.3.3^
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
    classpath 'com.google.gms:google-services:4.3.3' 
}
}
//################################################################################
allprojects {
    repositories
            {
                google()
                jcenter()
                mavenCentral()
                maven { url "https://dl.google.com/dl/android/maven2/" }
                maven { url "http://jcenter.bintray.com/" }
                maven { url 'https://plugins.gradle.org/m2/'}
                maven { url "https://maven.google.com" }
                maven { url 'https://jitpack.io' }
                maven { url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api' }

                flatDir {
                    dirs 'libs'
                }
            }
}
//################################################################################
task clean(type: Delete) {
    delete rootProject.buildDir
}
Finfoot answered 10/1, 2020 at 12:34 Comment(0)
T
0

im my case I solved the problem by downgrading gradle version from 3.6.3:

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

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

to 3.4.2:

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

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
Tarlatan answered 22/6, 2020 at 16:17 Comment(0)
D
0

Do not comment out google(), while applying the solutions above:

repositories {
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    jcenter()
    google()
    maven {
        url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api'
    }
}
Deepfry answered 12/5, 2021 at 2:56 Comment(0)
S
0

For me just deleting .gradle folder in directory of C:\Users\[Your User] and rebuild project worked.

Stormy answered 25/7, 2022 at 6:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.