Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 933
Jeff Avatar asked Oct 22 '25 09:10

Jeff


1 Answers

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

like image 155
CodeHat Avatar answered Oct 24 '25 23:10

CodeHat