React Native android app not working in release
Asked Answered
C

6

10

I made an app using react native. The app connects to the api that I made. I followed these steps : https://facebook.github.io/react-native/docs/signed-apk-android, and now the app doesn't work if i do react-native run-android --variant=release.The app installs, but I can't login in the app. Is there any way to see if I get any errors or something?

I tried searching for a way to show the debbuging console even if the variant is release, but i can't find any

I want the app the work as the one that is not in release variant.

Cultivable answered 31/7, 2019 at 11:13 Comment(3)
is it a http or https request?Kerenkeresan
it is a http requestCultivable
When you have the release variant on your device, plug it in and open LogCat. Select your device, select the bundle identifier matching your app. Upon crash, you will receive a stack trace. Can you paste the stack trace in your question?Bischoff
P
37

maybe you need to add android:usesCleartextTraffic="true" inside the application tag in the AndroidManifest.xml .

Something like this:

<application
  ...
  android:usesCleartextTraffic="true"
  ...
>
   ...
</application>
Palma answered 31/7, 2019 at 12:40 Comment(5)
And after i modify this, do I need to do gradlew assembleRelease, or just rerun with run-android --variant=release? I'm not sure how it works... it's my first appCultivable
just run-androidPalma
Oh my God.... thank you so much... i've been tring this all day... thank you a lot... Now i have one more question if you could help me. Now that i added this, do i have to do all the steps <a href='facebook.github.io/react-native/docs/…> or does it save somehow automatically?Cultivable
I'm glad to hear that! About the second question, If you did all that steps you just have to create a new APK by assembleRelease and upload a new version to Google Play. Remember to change the compileVersion and the NameVersion and would be all donePalma
Modify it in /<Project Folder>/android/app/src/main/AndroidManifest.xmlMatronize
K
1

I think the issue is because it's an http request.

This might fix your issue: https://mcmap.net/q/35721/-how-to-allow-all-network-connection-types-http-and-https-in-android-9-pie

Kerenkeresan answered 31/7, 2019 at 12:38 Comment(1)
Yes, that was it. @mtg-kha-jeskai responded and it worked. Thank you for your answer to.Cultivable
V
0

Please try to be precise or else its difficult to understand the problem.

In order to catch the issues in release mode we have couple of libraries which will help us debug even when the real user is using the app. Check the below two libs they might help you find the issue.

  1. Busgnag
  2. Crashalytics, a module in react-native-firebase
Vernellvernen answered 31/7, 2019 at 11:22 Comment(1)
I made the app. It works when I run it with react-native run-android. I get no errors or anything. When I try to run it with react-native run-android --variant=release, it installs the app, it launches the app, but when I press the login button just.... nothing hapens... I don't get any errors or anything... it just doesn't redirect me from the Sign in screen to the App screenCultivable
K
0

For me, I saw the same behavior but the reason was very different than the accepted solution. I'll leave my answer here in case it helps someone else.

TL;DR: Make sure your emulator/device has the correct time!

The Problem

If you're using HTTPS, the device and server time need to be in sync or it will not allow a connection.

Normally that's not a problem, but my emulator has been resetting its time for some reason. The result is that when I connected in debug mode the time was right and it connected just fine. However, the time was wrong when I switched to release mode and did NOT connect.

The problem was subtle because my build variants use different servers, so my secure connection in debug was cached and still valid even after the time changed and release mode did not work, which made this look like an issue with build configs.

The Solution

You can very easily find out if this is your same issue by

  1. Checking the time on your device
  2. Opening the URL in a browser. The browser will likely notice the time-difference issue and alert you about it.

If it is, just go into your device settings, update the time, and it should work!

Kenyatta answered 14/7, 2023 at 13:46 Comment(0)
N
0

just add ----- android:usesCleartextTraffic="true"--- in AndroidManifest.xml file like below

<application
  ...
  android:usesCleartextTraffic="true"
  ....
  >
 </application> </manifest>
Nerveracking answered 21/11, 2023 at 5:57 Comment(0)
A
0

Ok in apk version out of 3 user only one user getting login the other given invalid request, react native version is 0.67.0

Ashlieashlin answered 29/8, 2024 at 9:10 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Magnuson

© 2022 - 2025 — McMap. All rights reserved.