I have a react native app that fetches books from a database and displays them. It works fine on iOS when the mongodb backend is running, but not on android. I just get a network error as shown below.
Do any of you know how to fix it?
Here is my 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()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.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' }
}
}
Here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />s
<uses-sdk android:targetSdkVersion="29" android:minSdkVersion="16" tools:overrideLibrary="com.facebook.react"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
Please let me know how to fix this.
Thanks.
(Please let me know in the comments if you need to see any frontend or backend files.)
I fixed this issue and thought the solution might help someone else. All that was happening was that the emulator was not getting localhost. To fix this, in my front end, I replaced localhost:3000 with 10.0.2.2:3000. It fixed the issue.
Instead of
.post('http://localhost:3000/login'...
it should be
.post('http://10.0.2.2:3000/login'...
Thanks to #Raghav Herugu for helping me solve the problem
Related
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
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.
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.
I am trying to set up my first parse project however its not going so well. I would think it should be very straight forward however im still having issues and there are no current tutorials on youtube that i can find that work. The latest tutorial i've found for it is 3 years old.
I'm trying to follow the instructions here:
https://docs.parseplatform.org/android/guide/#installation
I've tried it 2 ways.
1) I have downloaded the parse project from github here:
https://github.com/parse-community/Parse-SDK-Android
Downloading this project comes with a lot of extras for this that are currently way over my head like folders for fcm, gcm, and ktx. The parse folder however also comes with a ton of classes.
I've been following tutorials which gave me a template parse project that was already set up however it was mean for android studio 2.2 i believe (Im currently running 3.3) When i would try to upgrade the files, it would give me tons of compatibility errors.
if anyone has any suggestions on how to fix this, i would greatly appreciate it. Here is what I have tried below:
i've followed the instructions in the link above however i get this error:
Could not find method implementation() for
arguments [com.github.parse-community.Parse-SDK-Android:parse:1.18.5] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
What i dont understand is that the instructions asked me to do this.
2) the second way i've tried it is that i've created a new project in android and i still get the same error at that line.
here is my gradle file for the ways i've tried it:
way number 1)
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.20.0'
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
compileSdkVersion = 27
supportLibVersion = '27.1.1'
firebaseJobdispatcherVersion = '0.8.5'
minSdkVersion = 14
targetSdkVersion = 27
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.parse">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="App"></application>
<application />
</manifest>
way number 2)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.parsetemplate">
<application
android:name="App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I was getting the same error when I followed parse README.MD
All you need to delete your current project and start a new one and follow the below guide.
https://www.back4app.com/docs/android/parse-android-sdk
You need to copy the complete repositories block, which is inside allprojects block from the build.gradle(Project: your_project_name), and paste it at the end of the build.gradle(Module: app) file.
After you have done that you should rebuild your project once.
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