in the android development java.net.SocketException: socket failed: EACCES (Permission denied) error p>
knowledge point:
1, SocketException network operation error;
2. Solutions; (turned out to be a single user to close our app networking permissions, now new android system can be set for a permission) span> strong> p>
today I met a user feedback, is that the problem encountered, click login, but unable to login, but prompt java.net.SocketException: socket failed: EACCES (Permission denied) this information. The first reaction is lack of network access, and then hurriedly check whether to join the network access.
adds
to the androidmanifest
<uses-permission android:name=“android.permission.INTERNET”/>
However, I already wrote it in the program. It’s rare to write an Android app project that doesn’t connect to the Internet, so this should be included in the first place. So, this problem is eliminated. However, I found a lot of information, but did not find a suitable description and solution. It can’t be me.
so here are some of the possible reasons I’m looking for.
but I don’t have the user’s phone, otherwise the log error will be clear. Now you have to ask the user to download the app again. And then it’s OK. This is a real pain in the ass.
There’s a new possible issue: users have disabled your app’s access to the network. Notice that it’s a single block. So give your application access to the Internet based on the system.
For example, the operation of xiaomi mobile phone is: find the “security center” app, enter, and then see the “network assistant”, enter, and then click “network control”, find the corresponding app, check whether the corresponding “data” and “WLAN” options are hooked.
or p>
Java file network operation, add the following code
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
reason:
is most likely because the code for the possible network operation was written in the UI thread, which has not been allowed since android 4.0. Because network operations are done in the UI thread, if the network is bad then the whole program is easy to ANR. So android4.0 will have to open a new thread for code that wants to operate on the network.
or
network permissions are written like this:
<uses-permission android:name=“android.permission.INTERNET"/>
instead of writing
<permission android:name=“android.permission.INTERNET"></permission>
or
important – the uses-permission tag needs to be before the application tag in the manifest file. thats what fixed it for me at least.
outside the wall say: permissions to be in < application> Only when the tag is introduced can it work. (but I write that all the time, no problem) — get rid of
or
after you restart the ide, you can run the code normally again.
total reason:
lack of permissions?
permission error?
network operation in UI thread?
port occupation caused?
android version issues?
development tool problem?Restart and recompile
Read More:
- Android has applied for permission and still prompts open failed: eacces (permission denied)
- Solve the problem of dynamically applying for permission, but still reporting an error of open failed: eacces (permission denied)
- java.net.SocketException: socket failed: EPERM (Operation not permitted)
- [Solved] Rabbitmq Warning: java.net.SocketException: socket closed
- NPM ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
- Unhandled rejection Error: EACCES: permission denied
- An error is reported when an android phone visits the app webpage: net::ERR_PROXY_CONNECTION_FAILED
- Unhandled rejection Error: EACCES: permission denied, open ‘/Users
- java.net.SocketException: Broken pipe (Write failed)
- mac Error: EACCES: permission denied, mkdir ‘./cache’
- ERROR: While executing gem … (Errno::EACCES) Permission denied @ dir_s_mkdir – /var/lib/gems
- Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’ npm ERR! at Error (native)
- Beeline connection hive2 reports an error permission denied
- solve java.net.SocketException : Unrecognized Windows Sockets error: 0: JVM_ Bind
- Caused by: java.net.SocketException : connection reset or caused by: java.sql.SQLRecoverableException solve
- Permission error: [errno 13] permission denied: ‘… ” xxx.pyd ‘
- fiddler dns lookup for failed System.Net.Sockets The name of the. Socketexception request
- -bash: /usr/java/jdk1.8.0_101/bin/java: Permission denied
- ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied
- PHP error Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Fatal error: