When I was creating one extension GIF creator it showed a bug

Hello guys, I am Abhinav Ranjan.
I was creating one extension called GIF Creator.
But it showed me on error.

My code :

package com.niotron.creatorgif;

import javax.imageio.ImageIO;

import javax.imageio.stream.FileImageOutputStream;

import javax.imageio.stream.ImageOutputStream;

import java.awt.image.BufferedImage;

import java.io.File;

public class CreateGifExample {

    public static void main(String[] args) throws Exception {

        BufferedImage first = ImageIO.read(new File("/tmp/duke.jpg"));

        ImageOutputStream output = new FileImageOutputStream(new File("/tmp/example.gif"));

        GifSequenceWriter writer = new GifSequenceWriter(output, first.getType(), 250, true);

        writer.writeToSequence(first);

        File[] images = new File[]{

                new File("/tmp/duke-image-watermarked.jpg"),

                new File("/tmp/duke.jpg"),

                new File("/tmp/duke-text-watermarked.jpg"),

        };

        for (File image : images) {

            BufferedImage next = ImageIO.read(image);

            writer.writeToSequence(next);

        }

        writer.close();

        output.close();

    }

}

Error shown :

Started Compiling Project GIFcreator
Buildfile: /compiler/android/build.xml

javac:
[mkdir] Created dir: /compiler/android/build/HwDui/classes
[javac] Compiling 1 source file to /compiler/android/build/HwDui/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /compiler/android/src/HwDui/com/niotron/creatorgif/GIFcreator.java:9: error: class CreateGifExample is public, should be declared in a file named CreateGifExample.java
[javac] public class CreateGifExample {
[javac] ^
[javac] /compiler/android/src/HwDui/com/niotron/creatorgif/GIFcreator.java:15: error: cannot find symbol
[javac] GifSequenceWriter writer = new GifSequenceWriter(output, first.getType(), 250, true);
[javac] ^
[javac] symbol: class GifSequenceWriter
[javac] location: class CreateGifExample
[javac] /compiler/android/src/HwDui/com/niotron/creatorgif/GIFcreator.java:15: error: cannot find symbol
[javac] GifSequenceWriter writer = new GifSequenceWriter(output, first.getType(), 250, true);
[javac] ^
[javac] symbol: class GifSequenceWriter
[javac] location: class CreateGifExample
[javac] 3 errors
[javac] 1 warning
1 Like

FYI - I made the extension in Niotron IDE

  1. You should ask in the niotron community.
  2. This happens if we just copy some code from the Internet without knowing what we do. (As you did) https://memorynotfound.com/generate-gif-image-java-delay-infinite-loop-example/
  3. As far as I know the javax image packages aren’t supported
  4. Here you will find all available extensions + extensions for gif handling
    App Inventor Extensions | Pura Vida Apps
4 Likes

It dosent matter what IDE you use, anyway Ai2 community is best place for such questions.

1 Like

First Mistake, You should declare your file name as CreateGifExample as class name. Also, to create the extension, you should inherit your class from AndroidNonvisibleComponent . Like,

public class CreateGifExample extends AndroidNonVisibleComponent{...}

What is GifSequenceWriter ? Compiler don’t know abonut GifSequenceWriter. You may have to import particular GifSequenceWriter class.

I am not sure this class is available at Android SDK or this class is part of Android. You should better look to Bitmap.

And there are many more errors.

I suggest you to look to AppInventor sources, and other open-source extensions to know better about extension development.

How to create extension by Hal Abelson
http://ai2.appinventor.mit.edu/reference/other/extensions.html

2 Likes

method of non supported javax.imageio.ImageIO

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.