2015-07-21 57 views
0

嗨,大家好,我注意到,在調用有時我的應用程序崩潰時/試圖發起我用下面的錯誤創建的類:安卓:無法找到我的項目中類最近

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); 
} 
} 

回答

0

不要知道這是原因,但考慮文檔提什麼:

getExternalStorageDirectory() Return the primary external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().

+0

你讓我的朋友很好。但爲什麼是NoClassDefFoundError異常?它不應該是不同的東西嗎? – user5035668

+0

你使用eclipse嗎? – yshahak

+0

不,我使用Android工作室 – user5035668