Search code examples
androidexceptionandroid-arrayadapterlogcatandroid-resources

Resources Not Found Exception


Hi i am getting a Resourcesnotfoundexception in my adapter code..

Code:

   public class Bag_adapter extends ArrayAdapter<Data> implements Filterable {
   //in getview()  
        {
         try {
                    int i = getContext().getResources()
                            .getIdentifier(name().toLowerCase(), "drawable", getContext().getPackageName());
                Log.wtf("Called", "Drawable=" + i);

                    holder.icon.setImageResource(i);
                } catch (Exception e) {
                    Log.wtf("Called", "Error=" + e);
                }
        }

Here is error logcat:

08-20 19:58:24.732 12650-12650/com.bot.pokego A/Called: Drawable=android.content.res.Resources$NotFoundException: Resource ID #0x7f0200bf
08-20 19:58:24.786 12650-12650/com.bot.pokego A/Called: Drawable=2130837716

I tried cleaning,deleted build folders also........but still same error.

I am using Android Studio .

Any help will be appreciated !.

Thanks ! inadvance :).


Solution

  • Check your resources folder. If you keep your resources in higher version folder v21 and test on lower version you may get this exception.

    Hope it helps !!!