Hi I am using Below package in react-native app
https://www.npmjs.com/package/firebase
My app uses firebase and firestore both
I have no issue in ios app
But in android app (firebase/firestore is not getting connected to internet)
Any idea ?
#firebase/firestore: Firestore (7.23.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
Android/build.gradle
// 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()
google() // Google's Maven repository
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.0')
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google() // Google's Maven repository
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' }
}
}
From the chat, I notice that you have not created Android app in Firebase console. Please create the app and generate the credentials and paste it in /android/app/. For more info on How to configure React Native app for Android and iOS, visit here.
In Android, we need request Internet permission for network action, maybe you missing it, let check your manifest.
Related
I opened up my build gradle because andoid emulator is not working and this is what I saw:
and this is the whole code:
build.gradle
import org.apache.tools.ant.taskdefs.condition.Os
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
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")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
I think this is the reason why android emulator is not working? What should I do to remove the error? Thank you in advance!!!
I faced the same issue while building my old application. I just upgraded my react-native project to the newer version and deleted the old build folder from "App/android/build".
To upgrade your project, go to the official link:
https://react-native-community.github.io/upgrade-helper/
select your version and the newer version you want to upgrade to.
after making changes to all the files mentioned there, delete the build folder.
Then run command "npx react-native run-android"
NOTE: You might get an error while creating or deleting a file or directory because of wrong permissions. Use commands below:
In linux : chmod 755 "/path of the showing error of permission"
In windows : run cmd as administrator
I am trying to build my RN app with eas:build. It is using gradle 7 and gradle 7 does not allow insecure protocol, I have already gone through this link. I understand that I need to add allowInsecureProtocol = true to the insecure maven repository. However, in my build gradle file I don't find any such maven repositories. So I don't know where to add this line to fix this issue. I investigated other packages gradle as well but so far I have not found any repo that has http.
This is my Gradle file,
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
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")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
}
}
You just need to add one line to the AndroidManifest.xml.
AndroidManifest.xml
<application
...
android:usesCleartextTraffic="true"> <= you add here
I am using the package #homee/react-native-mapbox-navigation for a turn by turn navigation. beneath you can see the depencies and versions:
"dependencies": {
"#homee/react-native-mapbox-navigation": "^1.1.0",
"react": "17.0.1",
"react-native": "0.64.2"
}
The package works fine when I set the property shouldSimulateRoute={true}. When I set it to false or remove it the app crashes on a androidphone. And on my simulator its gives me a wrong location.
This is my gradle.build:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// 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")
}
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = "mapbox"
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
in my AndroidManifest.xml file I added this line of code
<meta-data android:name="MAPBOX_ACCESS_TOKEN" android:value="code_here" />
And in my MainApplication.java I imported this:
import com.homee.mapboxnavigation.MapboxNavigationPackage;
The strange thing is that it all works fine when shouldSimulate is true when I set is to false as the default should be it doesn`t work anymore.
Does someone know how to fix this?
Thx!
I have solved the problem. It looks like if you turn off the shouldSimulateRoute property and set it to false you have to use the users current location, so you cant hardcode it. this helped for me!
Recently I´ve created a new React Native App with the default.. basically everything. On the emulator, it works fine, but, when I try to install it on Android Oreo, it shows an "Application not Installed" message.
I´ve already generated a signed APK as I read in other posts regarding the same issue.
Maybe I should downgrade my RN Version..
Here´s my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 16
compileSdkVersion = 30
targetSdkVersion = 30
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// 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' }
}
}
Thanks in advance!
I´ve had to downgrade my React Native version to 0.63 in order to make it work.
I am trying to Sync a React-Native project in Android studio, whenever I try to sync it, it throws an error as below,
Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jaa r
I tried lot of methods mentioned earlier for the same issue for Cordova and other project But I can't see it work for my React-Native.
My build.gradle file is looks like following
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
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()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
}
}
Duplicated Questions answers are looks like for Cordova, but My question is about to React-Native, and I tried all the answers there none of they are not working
It appears that jcenter was broken yesterday. In your build.gradle file, move jcenter() below google() (both places).
For more information:
https://github.com/facebook/react-native/issues/21907#issuecomment-432319128
Make this particular change under android/CordovaLib/build.gradle
repositories {maven {
url "https://maven.google.com"} jcenter()}
Note: add jcenter() after maven and use cordova platform add android#7.1.1 to add platfrom