question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch not working in release APK

See original GitHub issue

🐛 Bug Report

I use a login in my app, when I test on development environment on my phone I have any trouble I can log in. But when I build the release APK it seems like the app can not connect with the fetch (the code enter in the catch of the fetch) My AndroidMainfest.xml has the INTERNET pemission

Code Example

fetch(config.urlServer + "/index.php/AppServer/signin", { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ email: this.state.email, password: this.state.password }) }).then(res => res.json()) .then((responseJson) => { console.log(responseJson); if(responseJson.result){ this.props.setSession(responseJson.user); this.props.navigation.navigate('Main'); }else{ Toast.show({ text: responseJson.error, buttonText: 'Cerrar', type: "danger" }); } }).catch((error) => { console.error(error); Toast.show({ text: 'Hubo un Error', buttonText: 'Cerrar', type: "danger" }); })

Environment

React Native Environment Info: System: OS: macOS 10.14 CPU: (4) x64 Intel® Core™ i5-5350U CPU @ 1.80GHz Memory: 72.54 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.9.0 - /usr/local/bin/node Yarn: 1.9.4 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 19, 23, 24, 26, 27, 28 Build Tools: 23.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3 IDEs: Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.3 => 0.59.3 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-rename: 2.4.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17

github_iconTop GitHub Comments

20reactions
hey99xxcommented, Apr 8, 2019

Make sure your config.urlServer is not an HTTP endpoint but should be HTTPS. Latest RN versions target recent Android SDK that blocks insecure HTTP connections automatically.

11reactions
gabrielrracommented, Sep 11, 2019

If anyone is facing the same issue, because of the “http” just add android:usesCleartextTraffic="true" to the Manifest, and you should be good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native release apk does not fetch data from local network
If I generate a debug APK and install it on the devices, it works fine and fetches data from the local database as...
Read more >
Api not working on release apk in android
Fetch not working in release apk. I have an Android app that has 2 different firebase projects, one for DEBUG builds and one...
Read more >
React Native release apk does not fetch data from local ...
Coding example for the question React Native release apk does not fetch data from local network-Reactjs.
Read more >
App doesn't work in release apk but works fine in debug mode
First clean the android project, then keep running yarn react-native run-android —variant=release until the app launches without crashing.
Read more >
API data not showing in Release version, but work correctly in ...
In flutter sometimes there is an error that API data not showing in the Release version but works correctly in the debug mode....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found