Jeff
Jeff

Reputation: 191

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.

Upvotes: 4

Views: 2030

Answers (2)

CodeHat
CodeHat

Reputation: 483

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

Upvotes: 2

Jeff
Jeff

Reputation: 191

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

Upvotes: 0

Related Questions