Universal Image Loader throws UnsupportedOperationException. Not sure why

廉价感情. 提交于 2019-12-13 04:29:39

问题


Everything is working great it would seem, however, UIL keeps throwing this exception. They are not fatal and are not crashing the app. My thoughts are that its just what UIL spits out when it can't find the image I'm sending it via a web uri.

Here is the exception below.

java.lang.UnsupportedOperationException: UIL doesn't support scheme(protocol) by default [/assets/attachments_missing/avatars/square_missing.png]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))

com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromOtherSource(BaseImageDownloader.java:206)
com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:95)
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:340)
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisc(LoadAndDisplayImageTask.java:307)
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:249)
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:131)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
java.lang.Thread.run(Thread.java:1019)

Here is my configuration for UIL:

DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
    .cacheInMemory()
    .cacheOnDisc()
    .showStubImage(R.drawable.wm_new_thumb)
    .showImageOnFail(R.drawable.wm_new_thumb)
    .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
    .defaultDisplayImageOptions(defaultOptions)
    .build();

    ImageLoader.getInstance().init(config);

回答1:


if you want to load images from assets folder using Android-Universal-Image-Loader then append "assets://" prefix with images paths in assets as:

String imageUri = "assets://attachments_missing/avatars/square_missing.png";
//... do same for other images..

and for more help see following issue regarding loading images from assets :

Does Android-Universal-Image-Loader support Asset folder?



来源:https://stackoverflow.com/questions/16679639/universal-image-loader-throws-unsupportedoperationexception-not-sure-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!