java.lang.NoClassDefFoundError for GIF image

I am playing a GIF image in the main window, just for testing the GifAnimation Library.

I used the following code as prescribed by the library…

import gifAnimation.*;

Gif myAnimation;

void setup() {
   size(400,400);
   myAnimation = new Gif(this, "goose_anim.gif");
   myAnimation.play();
}

void draw() {
   image(myAnimation, 10, 10);
}

I get the following error…

FATAL EXCEPTION: Animation Thread
Process: processing.test.testgif, PID: 11663
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/image/BufferedImage;
at gifAnimation.GifDecoder.readImage(Unknown Source:131)
at gifAnimation.GifDecoder.readContents(Unknown Source:21)
at gifAnimation.GifDecoder.read(Unknown Source:28)
at gifAnimation.Gif.createDecoder(Unknown Source:9)
at gifAnimation.Gif.<init>(Unknown Source:14)
at processing.test.testgif.testGIF.setup(testGIF.java:27)
at processing.core.PApplet.handleDraw(PApplet.java:1801)
at processing.core.PSurfaceNone.callDraw(PSurfaceNone.java:471)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:503)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.image.BufferedImage" on path: 
DexPathList[[zip file "/data/app/processing.test.testgif-Q3STI5jY7Vf5yp95- 
     ngzCA==/base.apk"],nativeLibraryDirectories=[/data/app/processing.test.testgif-Q3STI5jY7Vf5yp95- 
     ngzCA==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 9 more

Did anyone else encounter this yet?
I am new to the library, so have never seen this…

Looks like you’re on Android from the stack trace? Don’t think BufferedImage exists on Android so don’t think that library can work as is.

1 Like

The sketch functions in Java mode, so thank you for your add.

Does this mean that the GifAnimation Library can only be used in Java mode and not in Android mode?

Can I avoid having to export it to Android Studio and then adding GIF ImageView to it?

Yes. It would need to be rewritten to only use classes available in both the full JDK and Android, or use specific functionality on each platform. Android is not a full Java implementation.

ok, this is of great help to me!
saves me a lot of time…

Thanks man!