Flutter team recently made this change and now insecure http connections are not allowed. https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android
I would like to know how can I connect my flutter app on mobile to local go server running on my PC.
My server is running on: http://192.168.29.45:4001 but it is not connecting to it.
Open the AndroidManifest. xml file in the android/app/src/main folder. Then set usesCleartextTraffic to true .
Generally it is required (and preferable) to use https links rather than http links. However, this can be overridden as shown below.
Open the AndroidManifest.xml file in the android/app/src/main folder. Then set usesCleartextTraffic
to true
.
<application
...
android:usesCleartextTraffic="true"
... >
See this question for more.
Open the Info.plist file in the ios/Runner folder. Then add the following key.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
See this answer for more.
This is the same as iOS. Open the Info.plist file in the macos/Runner folder. Then add the following key.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
As I have already answered. To temp fix your problem. First add the following config in the file named network_security_config
inside res/xml directory(my full path is /Users/dolphin/source/third-party/Cruise/android/app/src/main/res/xml/network_security_config
):
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
then in your AndroidManifest.xml file, inside <application
tag, add the following config:
android:networkSecurityConfig="@xml/network_security_config"
this could allow http traffic. But it just using to debug in your local env or test env, the best way is to using https traffic. more info: How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?
The easy way to implement this is to use this attribute inside your AndroidManifest.xml this will allow http traffic:
<application android:usesCleartextTraffic="true">
</application>
More info here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With