gpt4 book ai didi

java.lang.SecurityException : Permission denied (missing INTERNET permission? ) 即使在 android list 中添加此权限

转载 作者:行者123 更新时间:2023-11-29 03:04:20 35 4
gpt4 key购买 nike

我知道很多人以前问过类似的问题。但我回避了很多,但我的问题并没有通过 stackoverflow 或其他网站上的先前答案解决:这是我的 list 文件:

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

我的课上有这段代码:

JSONObject json = jParser.makeHttpRequest("http://sirsaleh.com/atu/atu.php", "GET", params);

但我每次都会看到这个运行时错误:

09-28 16:22:28.579    9558-9597/ir.atue.atufeed E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:612)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:495)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:473)
at ir.atue.atufeed.JSONParser.makeHttpRequest(JSONParser.java:65)
at ir.atue.atufeed.takeit$LoadAllProducts.doInBackground(takeit.java:106)
at ir.atue.atufeed.takeit$LoadAllProducts.doInBackground(takeit.java:84)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
            at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
            at java.net.InetAddress.getAllByName(InetAddress.java:214)
            at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
            at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
            at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
            at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
            at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:612)
            at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:495)
            at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:473)
            at ir.atue.atufeed.JSONParser.makeHttpRequest(JSONParser.java:65)
            at ir.atue.atufeed.takeit$LoadAllProducts.doInBackground(takeit.java:106)
            at ir.atue.atufeed.takeit$LoadAllProducts.doInBackground(takeit.java:84)
            at android.os.AsyncTask$2.call(AsyncTask.java:287)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)

最佳答案

以这种方式将您的许可放在 list 中:

<manifest ... >

...

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

<application ...

</manifest>

关于java.lang.SecurityException : Permission denied (missing INTERNET permission? ) 即使在 android list 中添加此权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32823599/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com