-1
java.lang.SecurityException: Permission denied (missing INTERNET permission?)
04-09 12:56:46.050 22026-22463/com.example.android.newsapp W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:451)
04-09 12:56:46.050 22026-22463/com.example.android.newsapp W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
04-09 12:56:46.050 22026-22463/com.example.android.newsapp W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:215)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:274)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:213)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:208)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.example.android.newsapp.RequestHandler.sendPostRequest(RequestHandler.java:60)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.example.android.newsapp.MainActivity$1UploadImage.doInBackground(MainActivity.java:114)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at com.example.android.newsapp.MainActivity$1UploadImage.doInBackground(MainActivity.java:88)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: at java.lang.Thread.run(Thread.java:818)
04-09 12:56:46.051 22026-22463/com.example.android.newsapp W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
04-09 12:56:46.055 22026-22463/com.example.android.newsapp W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method)
04-09 12:56:46.056 22026-22463/com.example.android.newsapp W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
04-09 12:56:46.056 22026-22463/com.example.android.newsapp W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:438)
04-09 12:56:46.056 22026-22463/com.example.android.newsapp W/System.err: ... 21 more
04-09 12:56:46.056 22026-22463/com.example.android.newsapp W/System.err: Caused by: android.system.ErrnoException: android_getaddrinfo failed: EACCES (Permission denied)
04-09 12:56:46.056 22026-22463/com.example.android.newsapp W/System.err: ... 24 more
這裏是清單文件「缺少Internet權限」和EACCESS在Android清單文件中添加用戶的權限被拒絕「儘管?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.newsapp">
<user-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
我認爲在相同的錯誤一些答案,但大家說添加INTERNET/ACCESS_NETWORK_STATE權限之外的應用程序標記。 我這樣做了,但沒有什麼值得發生。 調試時,我發現,在sendPostRequest方法是不要去try塊,但直接轉移至catch塊。
我在新的計算器就可以知道爲什麼的問題是downvoted? – TheDominus
您正在使用網絡......錯誤清楚地說明「沒有與主機名關聯的地址」,這意味着您的DNS請求失敗。 –
當您提出有關android權限的問題時,請同時發佈您的manifest.xml –