Example, we use socket.io-client-java
:
mSocket = IO.socket("http://192.168.1.10:11111", opts);
And we see in Logcat:
No Network Security Config specified, using platform default
This occurs to the api 28 and above, because doesn’t accept http anymore, you need to change if you want to accept http or localhost requests.
Solution:
Step 1:
In Android Manifiest, in tag application add:
android:usesCleartextTraffic="true" android:networkSecurityConfig="@xml/network_security_config"
Step 2:
create in folder app\src\main\res\xml
this file network_security_config.xml
and write this:
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <base-config cleartextTrafficPermitted="true" /> </network-security-config>
Step 3:
inside tag application add this tag:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
1 Comment
Android Error: CLEARTEXT communication to not permitted by network security policy | Free Online Tutorials
(February 23, 2021 - 2:04 am)[…] This problem is similar to the problem: Android: how to fix: No Network Security Config specified, using platform default […]