一、问题描述

UniversalAndroidImageLoader出现异常:ImageLoader:Unable to resolve host "https"No address associated with host
使用 ImageLoader 时,出现如下错误,始终加载图片错误,显示 img_error 的图片 UniversalAndroidImageLoader 出现异常: ImageLoader: Unable to resolve host "https": No address associated with host

E/ImageLoader: failed to connect to https/183.221.250.11 (port 443) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
    java.net.ConnectException: failed to connect to https/183.221.250.11 (port 443) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
    at libcore.io.IoBridge.isConnected(IoBridge.java:267)
        at libcore.io.IoBridge.connectErrno(IoBridge.java:191)
        at libcore.io.IoBridge.connect(IoBridge.java:127)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:461)
        at java.net.Socket.connect(Socket.java:918)
        at com.android.okhttp.internal.Platform.connectSocket(Platform.java:174)
        at com.android.okhttp.Connection.connect(Connection.java:152)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:282)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:216)
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:391)
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:341)
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:509)
        at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
        at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
        at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:117)
        at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)
        at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:98)
        at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:74)
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:265)
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:238)
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)
    Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
        at libcore.io.IoBridge.isConnected(IoBridge.java:252)
        at libcore.io.IoBridge.connectErrno(IoBridge.java:191)?
        at libcore.io.IoBridge.connect(IoBridge.java:127)?
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188)?                             
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:461)?
        at java.net.Socket.connect(Socket.java:918)?
        at com.android.okhttp.internal.Platform.connectSocket(Platform.java:174)?
        at com.android.okhttp.Connection.connect(Connection.java:152)?
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:282)?
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:216)?
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:391)?
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:341)?
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:509)?
        at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)?
        at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)?
        at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:117)?
        at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)?
        at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:98)?
        at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:74)?
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:265)?
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:238)?
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136)?
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)?
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)?
        at java.lang.Thread.run(Thread.java:818)?

二、错误解决

2.1 添加权限(权限未添加)

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

2.2 已添加权限,但仍旧出现异常

  • android进入应用管理,清除缓存,清除数据。
  • 或者直接下载该引用,重新上载。即可解决问题。

2.3 出现问题的原因

以后将做探讨