WebCachedImageView初始化错误

时间:2013-11-28 13:04:52

标签: android android-imageview

我尝试使用这个库:

https://github.com/leocadiotine/WebCachedImageView/

我使用Emulator,API级别17,将WebCachedImageView添加到ListView抛出ListViewAdapter

public View getView(int pos, View child, ViewGroup parent) {
    Holder mHolder;
    LayoutInflater layoutInflater;
    if (child == null) {
        layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        child = layoutInflater.inflate(R.layout.sent_listview_item, null);
        mHolder = new Holder();
        mHolder.txt_fileName    = (TextView) child.findViewById(R.id.txt_sentLV_fileName);
        mHolder.img_preview     = (WebCachedImageView) child.findViewById(R.id.wciv);
        child.setTag(mHolder);
    } else {
        mHolder = (Holder) child.getTag();
    }
    mHolder.txt_fileName.setText(fileName.get(pos));
    return child;
}

public class Holder {
    WebCachedImageView img_preview;
    TextView txt_fileName;
}

我收到了这个错误:

11-28 15:47:51.767: ERROR/AndroidRuntime(1432): 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:856)
    Caused by: java.lang.NoClassDefFoundError: com.jakewharton.DiskLruCache
    at io.leocad.webcachedimageview.CacheManager$2.doInBackground(CacheManager.java:93)
    at io.leocad.webcachedimageview.CacheManager$2.doInBackground(CacheManager.java:86)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    ... 4 more

我想到这个错误:

mDiskCache = DiskLruCache.open(cacheDir, 1, 1, DISK_CACHE_SIZE); https://github.com/leocadiotine/WebCachedImageView/blob/master/code/src/io/leocad/webcachedimageview/CacheManager.java#L93

Plase帮帮我

1 个答案:

答案 0 :(得分:0)

我做到了。

由于问题是这个类的初始化:

Caused by: java.lang.NoClassDefFoundError: com.jakewharton.DiskLruCache

我删除了依赖DiskLruCache并在ClassPath中重新添加了。

这激发了我对这篇文章的启发: http://javarevisited.blogspot.ru/2011/06/noclassdeffounderror-exception-in.html