Can't access a remote API on release apk, app has internet permission

928

Solution 1

I fix this issue, It's because I edit my packages name, I think there's some problem on there. I build new project and it run smoothly

Solution 2

It's because by default http requests are disabled is release mode. Use the following code to enable it.

<manifest 
  xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
  android:usesCleartextTraffic="true" tools:targetApi="28"> 
... 
</application>

usesCleartextTraffic="true" is the key setting here.

I was fortunate enough to find this solution on GitHub

Share:
928
Jeff
Author by

Jeff

Updated on December 12, 2022

Comments

  • Jeff
    Jeff over 1 year

    The issue is with an http.get request, for some reason I can't access my API on release versions, but it runs smoothly in debug mode.

    I already gave internet permission on android/app/AndroidManifest.xml, and I already tested the permission by using Image.network, and I got the image.

    • Chris Reynolds
      Chris Reynolds almost 5 years
      We need some code to see what is wrong. However ‘localhost’ Is a common problem because it tries to use ip6 rather than ip4. If you are using localhost, try 127.0.0.1
    • Apin
      Apin almost 5 years
      There will be some log on your logcat
    • Jeff
      Jeff almost 5 years
      I fix this issue, It's because I edit my packages name, I think there's some problem on there. I build new project and it run smoothly