Created
December 27, 2019 14:12
-
-
Save ankittyagii/2f1b541ae88fc54bc1969afa1ba45e1b to your computer and use it in GitHub Desktop.
How to enable Cleartext in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Solution 1. Open AndroidManifest file. | |
<?xml version="1.0" encoding="utf-8"?> | |
<manifest ...> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<application | |
... | |
android:usesCleartextTraffic="true" | |
...> | |
... | |
</application> | |
</manifest> | |
Solution 2. | |
a. Create new file network_security_config.xml in res/xml/ folder. | |
<?xml version="1.0" encoding="utf-8"?> | |
<network-security-config> | |
<domain-config cleartextTrafficPermitted="true"> | |
<domain includeSubdomains="true">your.domain.com</domain> | |
</domain-config> | |
</network-security-config> | |
b. Add the network_security_config.xml in AndroidManifest | |
<application | |
android:name="...." | |
android:networkSecurityConfig="@xml/network_security_config" | |
... /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment