java.net.SocketException: socket failed: EPERM (Operation not permitted)

后端 未结 8 1180
轮回少年
轮回少年 2020-11-28 05:22

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

相关标签:
8条回答
  • 2020-11-28 06:05

    Set android:usesCleartextTraffic="true" in the manifest file. Add the permission INTERNET. Uninstall app and then install again.

    0 讨论(0)
  • 2020-11-28 06:06

    Solved: All I needed to do was to uninstall the app from the emulator or physical connected device and run it again.

    0 讨论(0)
  • 2020-11-28 06:11

    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" />
    
    0 讨论(0)
  • 2020-11-28 06:12

    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

    0 讨论(0)
  • 2020-11-28 06:16

    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" />
    
    0 讨论(0)
  • 2020-11-28 06:18
    1. Add ACCESS_NETWORK_STATE permission in manifest
    2. Reinstallation emulator
    0 讨论(0)
提交回复
热议问题