Search code examples
androidbitmapfactory

How do I investigate an issue with loading a bitmap using BitmapFactory in Android? "getEntry failing because entryIndex..."


I'm trying to load a bitmap and display it on a canvas. I've done it previously using this method and it's worked fine. Unfortunately, something has gone wrong this time and I don't know how I can track down the problem.

My code gets to here:

Log.d(TAG, "Loading bitmaps");
this.stageL=BitmapFactory.decodeResource(getResources(), R.drawable.stagel);
Log.d(TAG,"Bitmap loaded");
int stageLHeight = stageL.getHeight();
Log.d(TAG,String.valueOf(stageLHeight));

But then I get a warning in the logcat in-between Loading bitmaps and Bitmap Loaded. After that the app force closes and I never see the value of stageLHeight.

Here's the logcat:

11-07 15:22:50.182: DEBUG/LabSetup(613): Loading bitmaps
11-07 15:22:50.182: WARN/ResourceType(613): getEntry failing because entryIndex 3 is beyond type entryCount 1
11-07 15:22:50.182: WARN/ResourceType(613): Failure getting entry for 0x7f020003 (t=1 e=3) in package 0 (error -2147483647)
11-07 15:22:50.182: DEBUG/LabSetup(613): Bitmap loaded
11-07 15:22:50.222: WARN/dalvikvm(613): threadid=9: thread exiting with uncaught exception (group=0x40014760)
11-07 15:22:50.222: ERROR/AndroidRuntime(613): FATAL EXCEPTION: Thread-10
11-07 15:22:50.222: ERROR/AndroidRuntime(613): java.lang.NullPointerException
11-07 15:22:50.222: ERROR/AndroidRuntime(613):     at com.cjs.duallaseralignment.LabSetup.SetCanvasSize(LabSetup.java:53)
11-07 15:22:50.222: ERROR/AndroidRuntime(613):     at com.cjs.duallaseralignment.MainAppPanel.onDraw(MainAppPanel.java:136)
11-07 15:22:50.222: ERROR/AndroidRuntime(613):     at com.cjs.duallaseralignment.MainThread.run(MainThread.java:56)

And in case it's useful, the R.java:

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
        public static final int mag=0x7f020001;
        public static final int magr=0x7f020002;
        public static final int stagel=0x7f020003;
        public static final int stager=0x7f020004;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}

Solution

  • Gosh darn it!

    As a last resort I deleted the images from the project and re-added them, and hey-presto! Weird...