Android:致命异常:java.lang.NoClassDefFoundError classes.ImageSdCardCache

时间:2015-07-21 08:32:02

标签: java android android-studio noclassdeffounderror

嘿伙计们,我在尝试启动ImageLoader时遇到错误。

这是我的图像加载器的外观:

private static void instantiateImageLoader(final Context context) {
    //INIT ImageLoader config

    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .showImageOnFail(R.drawable.home_icon_image_not_available) // resource or drawable
            .cacheOnDisk(true)
            .cacheInMemory(false)
            .imageScaleType(ImageScaleType.EXACTLY) // default
            .bitmapConfig(Bitmap.Config.RGB_565)
            .resetViewBeforeLoading(true)
            .displayer(new FadeInBitmapDisplayer(300, true, true, true))
            .build();


    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) //it gives the fatal exception here
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new WeakMemoryCache())
            .diskCache(new ImageSdCardCache(new File(Environment.getExternalStorageDirectory().getPath() + "/MyAppCache/cache")))
            .defaultDisplayImageOptions(options)
            .memoryCacheExtraOptions(300,300)
            .build();

    ImageLoader.getInstance().setDefaultLoadingListener(new ImageLoadingListener() {
        @Override
        public void onLoadingStarted(String s, View view) {
        }

        @Override
        public void onLoadingFailed(String s, View view, FailReason failReason) {
            if(view!=null) {
                ((ImageView) view).setScaleType(ImageView.ScaleType.CENTER);
                ((ImageView) view).setImageDrawable(context.getResources().getDrawable(R.drawable.home_icon_image_not_available));
            }
        }

        @Override
        public void onLoadingComplete(String s, View view, Bitmap bitmap) {

        }

        @Override
        public void onLoadingCancelled(String s, View view) {


        }
    });

    ImageLoader.getInstance().init(config);
}

这是我的日志:

com.myapp.classes.Essentials.instantiateImageLoader (Essentials.java:111)   
com.myapp.classes.Essentials.start (Essentials.java:57) 
com.myapp.user.Splash.onCreate (Splash.java:76) 
android.app.Activity.performCreate (Activity.java:5275) 
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1087)    
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2169) 
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2255)  
android.app.ActivityThread.access$800 (ActivityThread.java:142) 
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1203)   
android.os.Looper.loop (Looper.java:136)    
android.app.ActivityThread.main (ActivityThread.java:5118)  
java.lang.reflect.Method.invokeNative (Method.java) 
dalvik.system.NativeStart.main (NativeStart.java)

我的ImageSdCardCache。 java类看起来像这样:

public class ImageSdCardCache extends BaseDiskCache {

public ImageSdCardCache(File cacheDir) {
    super(cacheDir);
}
}

可能是什么问题?我在我的项目的libs文件夹中添加了图像加载器库(universal-image-loader-1.9.4.jar)。

0 个答案:

没有答案