I have implemented webView in flutter but it is not opening my php website which is on server what I\'m doing wrong.
I am new to flutter and tried webview to integra
set usesCleartextTraffic property to true in your AndroidManifest file, like below.
<application
....
android:usesCleartextTraffic="true"
....>
In AndroidManifest.xml, add [android:usesCleartextTraffic="true"
] as
<application
......
.......
android:usesCleartextTraffic="true"
.............. >
<.........
................... />
..........
...........>
</application>
it not working in android version 9
Open the android manifest file (android/app/src/main/AndroidManifest.xml) and add
android:usesCleartextTraffic="true" to the application tag
<application
android:name="io.flutter.app.FlutterApplication"
android:label="tangerine_ui"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
In main directory of your Flutter project you have three main folders:
- lib = your Dart code
- ios = generated structure for iOS platform
- android = generated structure for Android platform
We are interested in android
directory.
When you open it, you will see "typical Android app structure".
So you have to do 2 things:
res
Go to directory:
my_flutter_project/android/app/src/main/res/
Create xml
directory (in res
!)
And inside xml
add new file with name: network_security_config.xml
and content:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
network_security_config.xml
should be located in path:
my_flutter_project/android/app/src/main/res/xml/network_security_config.xml
Here you can find more information about this file:
https://developer.android.com/training/articles/security-config
Go to:
flutter_project/android/app/src/main/AndroidManifest.xml
AndroidManifest.xml
is XML file, with structure:
<manifest>
<application>
<activity>
...
</activity>
<meta-data >
</application>
</manifest>
So for <application>
PROPERTIES you have to add 1 line:
android:networkSecurityConfig="@xml/network_security_config"
application
opening tag):<application
SOMEWHERE HERE IS OK
>
Not as a tag:
<application> <--- opening tag
HERE IS WRONG!!!!
<application/> <--- closing tag
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>