Android Eacces (Permission denied) and Permission denied anomaly probe

Source: Internet
Author: User

Words, Accipiter June, recently began to learn Android, remember the beginning or 09 years of learning, now the phone or Huawei out of the earliest Android phone C8500, at that time want to learn Android, earn a little money, but I did not insist on learning! Hate yourself so many years Ah! So now from the beginning to learn Android has a kind of archaeological exploration of the feeling AH! Get to the point, and today you'll be exploring a classic anomaly in Android.

First, enter the Chamber of Secrets

Well, one is I want from the vast Internet refill things, second, I want to give the vast internet to provide something, my own service, how to let the small partners see, now the small partners are popular mobile, but also the entire mobile platform. Helpless, wrote a few lines of code, reported a java.net.ConnectException:socket failed:eacces (Permission denied) abnormal. It's like a door to the Chamber of Secrets, and from there it has to go sightseeing.

Second, the Chamber of Secrets

Encounter problems, first read the log, although it is small white, but there is the Internet big God in the side, believe that God horse is not a secret! Search Now! Search, ha, same boat really much! There is the "http://www.cnblogs.com/Lewis/p/3298994.html" that is directly the problem, and there is: Java.io.IOException:open failed: Eacces (Permission denied) "http://blog.csdn.net/liranke/article/details/17239977", summed up, are and Permission "HTTP/ HI.BAIDU.COM/SPARE_H/ITEM/1C1B4EE8941E04F0E1A5D4CD "has a relationship. God horse? There are also "https://www.java.net/node/703177" that are related to the JDK.

Third, Secret room secrets

1. The most immediate is the java.net.ConnectException:socket failed:eacces (Permission denied) Anomaly, This only needs to be added in the Androidmanifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

2. What? Added, still did not see the truth Ah! Oh, you're in a position, right? There is a solution to the location error in "Http://stackoverflow.com/questions/8854359/android-open-failed-eacces-permission-denied" , but the Android I use is not recommended to add:

    </application></manifest>

The position between, give a warning, I put on <application> to go after, just fine.

3. Ah, the position is right, why still didn't see the truth? That depends on the Android version you use, this time the log should be reported:android.os.NetworkOnMainThreadException Exception according to "Http://www.cnblogs.com/Lewis /p/3298994.html ", basically 4.0 after the version of Android due to the possibility of blocking, the process of suspended animation, it is not recommended to write directly in the activity, you have to really want to use the addition:

Strictmode.setthreadpolicy (New StrictMode.ThreadPolicy.Builder (). Detectdiskreads (). Detectdiskwrites (). Detectnetwork (). Penaltylog (). build ());

Where do you add them? This is where I added the Java File connection request to the beginning .

But after I use 3.0 of the virtual machine test, reported Java.lang.SecurityException:Permission denied (missing INTERNET Permission?) Abnormal, then still reported:

Android.os.NetworkOnMainThreadException exception. It can be solved in the same way.

4. The normal truth should already be understood, but the JDK God horse has the influence, here also has a solution: more digging around and it seems the VPN client have IPv6 disabled which is causing is Sues with JDK7. If I use the following flag-djava.net.preferipv4stack=true I no longer see the errors. From "https://www.java.net/node/703177"

5. Or not, then you can try to restart all of them and start over again "http://stackoverflow.com/questions/17549920/socket-failed-eacces-permission-denied 】

6. My doubts, after these several times the toss, saw a lot of doubts, also have a lot of doubts. But my doubts are still there. 艹, incredibly put Androidmanifest.xml in Android.permission.INTERNET written android.premission.internet! this ~ ~ ~ All of the original question is to ask yourself ~ ~ ~ All the doubts are self-doubt oneself ~ ~ All terror is oneself frighten oneself!

End of the probe!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.