As I mentioned in the title, I wanted to creating the gif using the codes below, but I got an error.
ArrayList<Bitmap> bitmaps = bitmapss;
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                AnimatedGifEncoder encoder = new AnimatedGifEncoder();
                encoder.setDelay(500);
                encoder.setRepeat(0);
                encoder.start(bos);
                for (Bitmap bitmap : bitmaps) {
                    encoder.addFrame(bitmap);
                }
                encoder.finish();
                File filePath = new File("/sdcard", "sample.gif");
                FileOutputStream outputStream;
                try {
                    outputStream = new FileOutputStream(filePath);
                    outputStream.write(bos.toByteArray());
                } catch (FileNotFoundException e) {
                } catch (IOException e) {
                }
            }
Error:
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.deneme, PID: 13712
    java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@c5215a7