Android:无法在我的项目

时间:2015-07-21 10:09:01

标签: java android class android-studio noclassdeffounderror

大家好,我最近注意到,有时我的应用程序在调用/尝试启动我创建的类时崩溃,并出现以下错误:

Fatal Exception: java.lang.NoClassDefFoundError com.myapp.classes.ImageSdCardCache

我试图在这样的活动中引用/调用ImageSdCardCache:

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

这里我试图启动一个ImageLoader,但有时(并非总是)它失败,没有找到类异常。我做错了什么?

这是ImageSdCardCache.java放置在与我的活动所在的文件夹不同的文件夹中。

public class ImageSdCardCache extends BaseDiskCache {

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

1 个答案:

答案 0 :(得分:0)

不确定这是否是原因,但请考虑在文档中提到的内容:

  

getExternalStorageDirectory()返回主外部存储目录。 如果用户已在其计算机上安装此目录,该目录可能无法访问,已从设备中删除,或者发生了其他一些问题。您可以使用getExternalStorageState()确定其当前状态。