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.

3
  • is it a http or https request? Commented Jul 31, 2019 at 11:18
  • it is a http request Commented Jul 31, 2019 at 12:08
  • 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? Commented Jul 31, 2019 at 12:55

6 Answers 6

40

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

Something like this:

<application
  ...
  android:usesCleartextTraffic="true"
  ...
>
   ...
</application>
Sign up to request clarification or add additional context in comments.

5 Comments

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 app
just run-android
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?
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 done
Modify it in /<Project Folder>/android/app/src/main/AndroidManifest.xml
1

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

This might fix your issue: https://stackoverflow.com/a/55834683/6667328

1 Comment

Yes, that was it. @mtg-kha-jeskai responded and it worked. Thank you for your answer to.
1

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!

Comments

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

1 Comment

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 screen
0

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

<application
  ...
  android:usesCleartextTraffic="true"
  ....
  >
 </application> </manifest>

Comments

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

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.