Home » Android » NDK / Middleware / HAL » How to create / change Android Boot Animation ?

How to create / change Android Boot Animation ?

Android boot animation is the loading animation that is played when your device starts up. In this post, we will show you how to change the default boot animation with the new animation in Andorid.

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 previously 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.

So, the normal bootanimation would contain, “desc.txt” and part0, part1, part2, …, part”n” directories where each part directory refers to one frame.

On Ubuntu / Linux

you can create the bootanimation.zip using below command,

$ zip --compression-method store -r bootanimation.zip desc.txt part0 part1 part2

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


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment