Android 使用通用映像加载程序时的EOFEException
我正在使用android中的通用图像加载程序库。它的工作完美,但我得到以下错误Android 使用通用映像加载程序时的EOFEException,android,image,android-studio,adapter,universal-image-loader,Android,Image,Android Studio,Adapter,Universal Image Loader,我正在使用android中的通用图像加载程序库。它的工作完美,但我得到以下错误 E/ImageLoader﹕ null java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579) at libcore.net.http
E/ImageLoader﹕ null
java.io.EOFException
at libcore.io.Streams.readAsciiLine(Streams.java:203)
at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579)
at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:827)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
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.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:291)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisk(LoadAndDisplayImageTask.java:274)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:230)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136)
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)
下面是我在应用程序类中的代码
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.resetViewBeforeLoading(true)
.cacheOnDisk(true)
.cacheInMemory(true)
.showImageForEmptyUri(R.mipmap.fico_not_found)
.showImageOnFail(R.mipmap.fico_not_found)
.displayer(new FadeInBitmapDisplayer(300))
.build();
ImageLoaderConfiguration config1 = new ImageLoaderConfiguration.Builder(getApplicationContext())
.defaultDisplayImageOptions(defaultOptions)
.memoryCache(new WeakMemoryCache())
.diskCacheSize(100 * 1024 * 1024)
.build();
this.imageLoader = ImageLoader.getInstance();
imageLoader.init(config1);
我在适配器类中使用了以下代码
imageLoader = ((Application)context.getApplicationContext()).getImageLoader();
imageLoader.displayImage(Utils.IMAGE_URL + image_name,parentViewHolder.logo);
有人犯过这样的错误吗?任何有关这方面的帮助都将不胜感激 这不是一个有充分记录的答案。在一些较新版本的安卓系统中,出现了一个回收url连接的错误。要解决此问题(尽管可能存在一些性能问题),您需要添加:
if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) {
urlConnect.setRequestProperty("Connection", "close"); //set URL connection property
}
为什么使用UIL libaray?他们不再维护那个图书馆了。尝试使用glide或毕加索。Piccaso:glide:@ZeeshanShabbir-我用的是毕加索,但没有办法管理缓存,所以我用的是UIL。你是否使用httpConnection获取图像url?@AkshayTilekar-是