I am working on an Android Studio project with several activities. I am currently trying to read the output from a Java Servlet on localhost but it seems to be crashing due
Set android:usesCleartextTraffic="true"
in the manifest file.
Add the permission INTERNET
.
Uninstall app and then install again.
Solved: All I needed to do was to uninstall the app from the emulator or physical connected device and run it again.
I had to uninstall the app from the emulator and then everything started to work. I just needed the folowing permission on the AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
First of all you need change your android manifest .xml But after this action you must uninstall application and run it again. https://developer.android.com/training/basics/network-ops/connecting
and code here:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
in AndroidManifest.xml
I had to delete this
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
and keep this
android:usesCleartextTraffic="true"
<uses-permission android:name="android.permission.INTERNET" />