Flutter Release apk cannot connect the internet on android 11.0 mobile device, but able to connect the internet on android 8.0

I got a strange problem that related to the Flutter. This is due to the problem that Flutter Release apk cannot connect the internet on android 11.0 mobile device (the device is Samsung A71). However when I tested the Flutter Release apk on android 8.0 mobile device and other virtual device (for all version of android), they don’t have such problem. I tried all the possible solution (like add the permission to access the internet), and updated the flutter to the newest version (2.0.4), but the problem still occurs. As I searched the related questions, no such case is happened for others. I would like to ask how to solve this kind of problem? Thanks!

Answer

make sure that you have added

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

with INTERNET in Capital letters

if this doesn’t solve the problem try to set network Security Config because in android 9 and above you have to set network Security Config

first of all in res package create xml package and in xml package create new xml resource file with network_security_config name

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

then in manifest

android:networkSecurityConfig="@xml/network_security_config"