How to create / change Android boot animation

bootanimation.zip – This is a zip after extracting, it contains following things

  • desc.txt – The first line from desc.txt indicates as, “Width” “Height” “Framerate”
  • android – folder with 00.png to 30.png images of 681300 px which are shown once during boot
  • loading – folder which has 31.png to 79.png of 681300 px which are shown repeatedly till device is booted completely.

Note: Bootanimation png files are png with 681*300 px and black background ( not transparent png )

$ vim create_bootanimation.sh 
#!/bin/bash

#run this script as bash create_bootanimation.sh filename.png
rm -rf bootanimation #delete if previosuly created any

BOOTANIMATION_DIR=$PWD/bootanimation
mkdir $BOOTANIMATION_DIR
STATIC_FILENAME=$PWD/$1

mkdir $BOOTANIMATION_DIR/android
mkdir $BOOTANIMATION_DIR/loading

echo "681 300 20" > $BOOTANIMATION_DIR/desc.txt
echo "p 1 0 android" >> $BOOTANIMATION_DIR/desc.txt
echo "p 0 10 loading" >> $BOOTANIMATION_DIR/desc.txt

cd $BOOTANIMATION_DIR/android
for i in {0..30}
do
        cp $STATIC_FILENAME $i.png
done

cd $BOOTANIMATION_DIR/loading
for i in {31..79}
do
        cp $STATIC_FILENAME $i.png
done

echo "bootanimation folder created at $BOOTANIMATION_DIR"

In above script, we are passing single image as STATIC_FILENAME which is used to create bootanimation but if you want to create real animation, you will need to generate multiple images of this animation and copy those to android and loading directory by modifying above script.

Now, copy this bootanimation folder to windows,

On Windows

select everything inside the bootanimation folder and zip them into a new compressed zip archive using 7-zip:
– Select everything inside the bootanimation folder.
– Right-click on any of the selected files/folders and from the 7-zip menu, select ‘Add to archive’.
– Use ‘zip’ as the archive format and ‘Store’ as the compression level, and click OK.

Note, here remember to select compression level to “Store” otherwise this bootanimation zip may not work. This will create a file called bootanimation.zip in the same folder.

Copy this bootanimation.zip to your android source and recompile to generate updated images which contains newly created bootanimation

OR, if you have root access, you can directly push this to android as,

$ adb push bootanimation.zip /sdcard/
$ adb shell
$ su
$ mount -o remount,rw /system
$ cd /system/media
$ mv /sdcard/bootanimation.zip .
$ chmod 644 bootanimation.zip
$ chgrp root bootanimation.zip
$ reboot

You should see a new bootanimation. 🙂

Reference – https://android.googlesource.com/platform/frameworks/base/+/master/cmds/bootanimation/FORMAT.md

Leave a Comment