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

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
Our repositories sections already contain google()
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

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

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

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'
}

Related

node_modules can't find com.android.tools.build:gradle:4.1.1

Recently Android Studio was kind enough to offer to upgrade to gradle 6.5.
Naive I was: I clicked yes, then the new upgrade occured and now everytime I build I get this error similar to:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
> A problem occurred configuring project ':react-native-fs'.
> Could not resolve all artifacts for configuration ':react-native-fs:classpath'.
> Could not find com.android.tools.build:gradle:4.1.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :react-native-fs
my android/build.gradle file has those lines:
buildscript {
repositories {
mavenLocal()
google()
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
So life's good for my project, but not for A LOT of modules, which have this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
}
To solve the issue, I need to add the google() repository.
... but I don't like manually editing any file under the node_modules/ folder as any new install with break them.
Is there a way to fix this ?
Just delete node_modules folder and run
yarn install
or
npm install
reopen project in Android Studio and thats it

How to fix 'Program type already present' in gradle

I'm trying to add "com.google.android.gms:play-services-auth:15.0.1" to my project, in dependencies node, and i'm getting an error when i'm running the project, the error is: Error: Program type already present: com.google.android.gms.internal.auth.zzas
I googled it, and i tried a lot of stackoverflow answers, but no one of them help, indeed no one of them really talking about my specific problem, in the end, i can't continue work on my project
Here's App Gradle:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-auth:15.0.1' // Make the error!
implementation 'com.google.firebase:firebase-config:15.0.2'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-database:15.0.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
.... }
Top Level Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com/' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I expect to compile my project and use "play-services-auth" library, but my project can not compile, Thanks!
After many attempts, I was just need to update the Gradle, and then everything is start to work.
Before.. I could not update the Gradle because an old version of OneSingal, thanks anyway..

how to fix "react-native-spinkit:unspecified"

What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-spinkit'.
Could not resolve all dependencies for configuration ':react-native-spinkit:classpath'.
Could not resolve com.android.tools.build:gradle:2.0.0.
Required by:
Myproject:react-native-spinkit:unspecified
Could not resolve com.android.tools.build:gradle:2.0.0.
Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.0.0/gradle-2.0.0.pom'.
Could not HEAD 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.0.0/gradle-2.0.0.pom'. Received status code 403 from server: Forb
idden
android/build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url "https://maven.google.com"
}
// Add jitpack repository (added by react-native-spinkit)
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
The issue seems to be related to the version not supported com.android.tools.build:gradle:2.2.3.
You can try two thing here -
1) upgrade the versions to latest and try to build again.
2) Try to change version as given below to check if its working with version 2.0.0 or not
classpath 'com.android.tools.build:gradle:2.2.3'
with
classpath 'com.android.tools.build:gradle:2.0.0'.
Hope it solves your problem !

How to fix Build failed with an exception

Can someone help me with this error?
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all files for configuration ':react-native-google-signin:debugCompileClasspath'.
Could not find play-services-auth.jar (com.google.android.gms:play-services-auth:12.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-auth/12.0.1/play-services-auth-12.0.1.jar
Try to replace your android/build.gradle with this i.e in your project level gradle with this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {url "https://maven.google.com"} //<---- this should be added and should be aboce jcenter
maven {url "$rootDir/../node_modules/react-native/android"}
jcenter()
}
}
After that clear your gradle going inside android folder from cmd/terminal
gradlew clean
Then run the react native application

A problem occurred evaluating project ':react-native-share'

I try this commands for the installation of the library react-native-share
npm install react-native-share --save
react-native link react-native-share
But i got this error:
A problem occurred evaluating project ':react-native-share'.
> Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
SOLUTION:
I follow this guide of a similar problem with the maps plugin of react.Link to guide
the following steps are the ones that work for me:
1_ Modify android/build.gradle
Add google() inside repositories
buildscript {
repositories {
jcenter()
// add google() here
google()
2_ Update com.android.tools.build.gradle to 3.1.0
buildscript {
repositories {
jcenter()
google()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.2.3'
// update from 2.2.3 to 3.1.0
classpath 'com.android.tools.build:gradle:3.1.0'
3_ Add google() inside repositories after dependencies
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
allprojects {
repositories {
mavenLocal()
jcenter()
// add googgle() here
google()
4_ Add android.enableAapt2=false to android/gradle.properties
android.enableAapt2=false // < --- add here
android.useDeprecatedNdk=true
5_ Update gradle version in android/gradle/wrapper/gradle-wrapper.properties
// from version 2.14.1
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
// change to 4.4
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6_ Run react-native run-android. (This might take a while since it’ll be downloading the updated gradle version).