Symptoms
- During the build, the following warning is logged to the console:
The application's Target API Level is set to 28 or higher, which means that Android will block requests to plain http:// (non-https) URLs by default.
- When the application tries to load a plain http:// URL at runtime, the webview displays a
net::ERR_CLEARTEXT_NOT_PERMITTED
error message.
Cause
Starting in Android 9.0 (API Level 28), Android now blocks applications from loading plain http:// URLs by default because traffic over those requests is unencrypted.
Resolution
If your application must support loading plain http:// URLs, you can opt into enabling cleartext traffic by using an AndroidManifest.xml file that includes an android:usesCleartextTraffic="true"
application attribute. You can do that with the following steps.
Download this example AndroidManifest.xml file that includes the needed
android:usesCleartextTraffic="true"
attribute.Place the file in your project at Assets/Plugins/Android/AndroidManifest.xml. This location must be exact or else Unity will not detect its presence.
Rebuild your application.
For more information, see this Stack Overflow answer.