Google Service download failure in gradle - react-native

Followed the instructions specified in firebase cloud platform. Getting this issue while running the gradle build.
Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.gms:google-services:4.3.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/gms/google-services/4.3.3/google-services-4.3.3.pom
- https://jcenter.bintray.com/com/android/gms/google-services/4.3.3/google-services-4.3.3.pom
Required by:
project :
build.gradle , with the artifact added.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
classpath("com.android.gms:google-services:4.3.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
Any inputs to the issue will help, checked firewall and proxy issues already.

There are two build.gradle files in an Android Project. One is for app-level and another one is for your project root-level.
In order to setup Firebase correctly, You have to write like following in your root-level (project-level) Gradle file (build.gradle):
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin like below snippet:
apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services' // Google Services plugin
android {
// ...
}
You are doing everything but in the app-level file. Try Fixing it and tell whether it worked or not.

Related

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

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

How to fix missing ReactContextBaseJavaModule symbol?

I wan't to create a custom native module for my app only - so no lib. Following the docs it gives me an error:
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Cannot resolve symbol 'ReactContextBaseJavaModule'
My app's android/app/build.gradle includes this line, which is included in all react-native modules I have used so far as well.
"com.facebook.react:react-native:+" // From node_modules
My android/build.gradle:
// 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.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}
}
Below are the steps I encountered and used to solve importing all the libraries related to React Native Libraries in the Android Studio:
First when I created a brand new react native library project using react-native-create-library command, the command generated iOS and Android files.
I opened the android folder using Android Studio.
The gradle build reported some errors and fixed the gradle issue by updating some values in build.gradle and gradle-wrapper.properties.
build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile 'com.facebook.react:react-native:+'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
After adding the above 2 changes, Click Sync Now or Try again. In this step if it asks to install the build version, please install.
Now Clean and Rebuild the project, On top status bar of the Android Studio:
Click Build --> Clean Project then
Click Build --> Rebuild Project
After step #5, React Native import errors should disappear and the libraries related to React Native must be imported.
Thanks.

Upgrading to Android Gradle Plugin 1.3 fails build due to check failure in Espresso tests

Before upgrading to Android Gradle Plugin 1.3, the custom lint scope was only Android source files.
After I upgraded to 1.3.1, my tests files started getting checked and as a scenario fails my custom lint rule, the build fails.
There is no documentation about this. I read some warnings have become fatal but nothing around test files getting scanned.
Anyone facing such an issue?
EDIT:
top level build.gradle
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'org.sonarqube.gradle:gradle-sonarqube-plugin:1.0'
}
}
allprojects {
repositories {
flatDir {
dirs './prebuilt-libs'
}
mavenCentral()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
Error:
HardCoding: Detects HardCoded "abc" string
../../src/androidTest/java/com/xyz/mobile/trips/test.java:108: HardCoding Found. (This is my custom lint rule)
hasExtra(CODE, "abc")