Petter Häggholm
Petter Häggholm

Reputation: 560

Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2)

My React Native build quite suddenly fails with an error, in spite of working just fine a day ago with no changes that appear relevant.

FAILURE: Build failed with an exception.

* What went wrong: A problem occurred configuring project ':react-native-document-scanner'.
> Could not resolve all artifacts for configuration ':react-native-document-scanner:classpath'.
   > Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar

Similar questions have been asked several times before, but the usual solution is to add google() to the repositories section. However

  1. Our repositories sections already contain google()
  2. google() already appears ahead of jcenter()

Snippet from build.gradle:

buildscript {
    repositories {
        // ...
        google()
        maven { url 'https://maven.google.com' }
        mavenLocal()
        mavenCentral()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}

// ...

allprojects {
    repositories {
        // ...
        google()
        mavenLocal()
        mavenCentral()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}

It may or may not be relevant, though I certainly find it peculiar, that it looks to me like it successfully downloads the same thing for other dependencies:

$ ls ~/.gradle/caches/modules-2/files-2.1/com.android.tools.lint/lint-gradle-api/26.1.2/*
/home/petter/.gradle/caches/modules-2/files-2.1/com.android.tools.lint/lint-gradle-api/26.1.2/8c54aedfe9da66e64402de04883cee083c127a3b:
lint-gradle-api-26.1.2.jar

/home/petter/.gradle/caches/modules-2/files-2.1/com.android.tools.lint/lint-gradle-api/26.1.2/f68c47a57523ed87b225532b98f2dd2ece9552bb:
lint-gradle-api-26.1.2.pom

Upvotes: 6

Views: 2690

Answers (3)

Atak
Atak

Reputation: 897

As you said the usual solution is to add google() to the repositories section. This actually also applies here. You just need to go to your node_modules -> react-native-document-scanner -> android -> build.gradle There, you need to modify buildscript part like the following:

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

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

You probably have jcenter() above google. google() is the same thing with

 maven {
            url 'https://maven.google.com/'
            name 'Google'
        }

Upvotes: 0

user2313617
user2313617

Reputation: 81

Run the following command inside the android folder of your react-native project:

"./gradlew build --refresh-dependencies"

This way you can find which node-module has issue in build.gradle. I found this issue was being caused bu react-native-share module. So I updated the version to 1.1.3 in package.json for react-native-share. The other alternative is to update the build.gradle file inside the /node-modules/react-native-share/android/ and move the google() above jcenter()

Upvotes: 1

Minsoo kim
Minsoo kim

Reputation: 132

In my case, it's related with Fabric module,

My imported Fabric module's version was 0.5.2 (also have problem 0.5.1)

I solved this to downgrade Fabric module's version from 0.5.2 to 0.5.0

When build is success then the .jar file is created at .gradle/..

So I can use 0.5.2 version again,

I think it can be related with module's version

Upvotes: 2

Related Questions