How to Create a Flashable Zip for Android System Mods
If you are an Android developer who wants to create apps that target the /system partition (e.g. root apps), there are specific cases where you need a flashable ZIP file for your want to create an app. This is done so that the app files can be properly installed on the /system partition.
Some other uses of flashable ZIP files are:
Reading: How to create a flashable zip file for android
- Changing the DPI
- Apply a custom font
- Apply a custom boot animation
- Remove or add system apps
Insert your Users messing around with the file system and moving files around manually is a waste of time for everyone involved – creating a flashable .zip file is a much more convenient way. This Appual guide will show you how to create a flashable zip file for Android.
We’ll also show you an addon.d script to make custom system changes survive a dirty ROM flash – so users don’t have to reflash your ZIP file for each update.
Requirements:
- A root file explorer (MiXplorer, Solid Explorer)
- ZipSigner (for signing zips) or the MiX Signer plugin if you are using MixPlorer
- A Nandroid backup is highly recommended
You should also prepare any files included in the zip – APKs, configs, boot animations, etc. Organize everything before we begin as this is a delicate process.
Custom Zip File Template
If You can get a ZIP template that you can adapt to your own needs or use as a basis for creating a flashable ZIP file here:
- TEMPLATE SCRIPT: DOWNL OAD LINK (basic commands / you have to add your custom values: apps, paths of ringtones, boot animation…)
- TEMPLATE ZIP: DOWNLOADLINK (examples are always welcome to better understand an explanation. It can help to understand how you structure your files).
The template should be enough to start using a custom script.
See also: How to Add a New Post in WordPress and Utilize all Features
You need to these are the main ones remembering paths since these are the things in the /system partition that your flashable zips usually target:
addon.d => Backup script to survive a dirty flash (e.g. from the GApps package used) app and priv-app => system apps to add or remove etc. => hosts file fonts => your fonts media => your bootanimation.zip media > audio > alarms => alarm media tones > audio > notifications = > Notification sounds Media > Audio > Ringtones => Ringtone sounds Media > Audio > ui => Sounds for various things like low battery, unlock, camera, … Root of /system for build.prop file
Thinking Always remember that files removed from these paths are restored be asked. installed after a dirty flash and files added manually will be removed. For this reason it is necessary to create a script that creates a backup of your /system mods.
Update script example
ui_print(“+-+”); ui_print(“| CLEAN FLASH SCRIPT |”); ui_print(“| |”); ui_print(“| by Primokorn |”); ui_print(“+-+”); run_program(“/sbin/busybox”, “umount”, “/system”); run_program(“/sbin/busybox”, “mount”, “/system”); ui_print(” “); ui_print(“***Delete Bloatware***”); delete_recursive( “/system/app/adaway.apk”, “/system/app/AdAway”, “/system/app/BasicDreams”, “/system/app/BookmarkProvider”, “/system/app/Calendar”, ” /system/app/CalendarWidget”, “/system/app/CMFileManager”, “/system/app/CMWallpapers”, “/system/app/DeskClock”, “/system/app/Eleven”, “/system/app/ Email”, “/system/app/ExactCalculator”, “/system/app/Exchange2”, “/system/app/Gello”, “/system/app/HexoLibre”, “/system/app/Jelly”, “/system/app/LiveWallpapersPicker”, “/system/app/LockClock”, “/system/app/messaging”, “/system/app/MiXplorer”, “/system/app/NexusLauncher”, “/system/app /Phonograph “, “/system/app/PhotoTable”, “/system/app/PicoTts”, “/system/app/PicoTTS”, “/system/app/ResurrectionStats”, “/system/app/SoundRecorder”, ” /system /app/Terminal”, “/system/app/TugaBrowser”, “/system/app/Wallpaper”, “/system/app/WallpaperPickerGoogle”, “/system/priv-app/AudioFX”, “/system/ priv-app/Chrome”, “/system/priv-app/Gallery2”, “/system/priv-app/MusicFX”, “/system/priv-app/OnePlusCamera”, “/syste m/priv-app/OnePlusGallery”, “/system/priv-app/OnePlusMusic”, “/system/priv-app/Recorder”, “/system/priv-app/Screencast”, “/system/priv-app/ Snap”, ” /system/priv-app/SnapdragonCamera”, “/system/priv-app/SnapdragonGallery”, “/system/priv-app/WeatherManagerService”, “/system/priv-app/WeatherProvider”, “/system /priv-app /shield” ); ui_print(“Installing apps and mods etc.”); show_progress(8.800000, 5); package_extract_dir(“system”, “/system/”); ui_print(“***Repair Permissions***”); set_perm(0, 0, 0755, “/system/addon.d/99-dirty.sh”); set_perm(0, 0, 0644, “/system/etc/gps.conf”); set_perm(0, 0, 0644, “/system/fonts/Roboto-Regular.ttf”); set_perm(0, 0, 0644, “/system/media/audio/ringtones/PlasticRing.ogg”); set_perm(0, 0, 0644, “/system/priv-app/Phonesky.apk”); set_perm(0, 0, 0644, “/system/priv-app/microG.apk”); set_perm(0, 0, 0644, “/system/priv-app/Gsam.apk”); set_perm(0, 0, 0644, “/system/priv-app/BBS.apk”); set_perm(0, 0, 0644, “/system/priv-app/V4A-Magisk.apk”); run_program(“/sbin/busybox”, “mount”, “/data”); package_extract_dir(” data”, “/data/”); set_perm(0, 0, 0755, “/data/local/afscript.sh”); show_progress(8.800000, 5); run_program(“/sbin/busybox”, “umount”, “/data”); run_program(“/sbin/busybox”, “umount”, “/system”); ui_print(” “); ui_print(“Done.”); ui_print(“Ready to reboot.”);
Note: ui_print(” “); is for text messages. These lines do nothing.
You should always unmount and remount the partition before working on it.
run_program (“/sbin /busybox”, “umount”, “/system”); run_program(“/sbin/busybox”, “mount”, “/system”);
To remove system components/apps, put a comma at the end of each line, except the last one.
delete_recursive( “/system/app/adaway.apk”, “/system/app/AdAway”, ………… …… …… “/system/priv-app/WeatherProvider”, “/system/priv-app/Tag” );
Extract the system files you want to install hten.
package_extract_dir(“system”, “/system/”); Set the file permissions. set_perm(0, 0, 0755, “/system/addon.d/99-dirty.sh”); ………….. set_perm(0, 0, 0644, “/system/priv-app/V4A-Magisk.apk”);
Do the same but for /data folder . So you mount the partition, extract the data you want to add and set the permissions.
run_program(“/sbin/busybox”, “mount”, “/data”); package_extract_dir(“data”, “/data/”); set_perm(0, 0, 0755, “/data/local/afscript.sh”);
See also: How To Create Folders in Gmail: A Step-by-Step Guide
Next, unmount the changed partitions.
run_program(“/sbin/busybox”, “umount”, “/ Data”); run_program(“/sbin/busybox”, “umount”, “/system”);
Example of Addon.D script
#!/sbin/sh # # /system/addon.d/99- dirty .sh # /system will be formatted and reinstalled, then these files will be restored. # . /tmp/backuptool.functions list_files() { cat <<EOF addon.d/99-dirty.sh fonts/Roboto-Regular.ttf media/audio/ringtones/PlasticRing.ogg priv-app/BBS.apk priv-app/ Gsam.apk priv-app/microG.apk priv-app/PhoneSky.apk priv-app/V4A-Magisk.apk etc/gps.conf etc/hosts EOF } case "$1" in backup) list_files | when reading FILE DUMMY; do backup_file $S/"$FILE" done ;; recovery) list_files | while read REPLACE FILE; do R="" [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R" done rm -rf /system/app/adaway.apk rm -rf /system/app/AdAway rm -rf /system/app/BasicDreams rm -rf /system/app/BookmarkProvider rm -rf /system/app/Calendar rm – rf /system/app/CalendarWidget rm -rf /system/app/CMFileManager rm -rf /system/app/CMWallpapers rm -rf /system/app/DeskClock rm -rf /system/app/Eleven rm -rf /system/app /Email rm -rf /system/app/ExactCalculator rm -rf /system/app/Exchange2 rm -rf /system/app/Gello rm -rf /system/app/HexoLibre rm -rf /system/app/Jelly rm -rf /system/app/LatinIME rm -rf /system/app/LiveWallpapersPicker rm -rf /system/app/LockClock rm -rf /system/app/messaging rm -rf /system/app/MiXplorer rm -rf /system/app/ NexusLauncher rm -rf /system/app/Nova.apk rm -rf /system/app/Phonograph rm -rf /system/app/PhotoTable rm -rf /system/app/PicoTts rm -rf /system/app/PicoTTS rm – rf /system/app/ResurrectionStats rm -rf /system/app/SoundRecorder rm -rf / system/a pp/Terminal rm -rf /system/app/TugaBrowser rm -rf /system/app/Wallpaper rm -rf /system/app/WallpaperPickerGoogle rm -rf /system/priv-app/AudioFX rm -rf /system/ priv-app /Chrome rm -rf /system/priv-app/Gallery2 rm -rf /system/priv-app/LatinIME rm -rf /system/priv-app/MusicFX rm -rf /system/priv-app/OnePlusCamera rm -rf /system/priv-app/OnePlusGallery rm -rf /system/priv-app/OnePlusMusic rm -rf /system/priv-app/Recorder rm -rf /system/priv-app/Screencast rm -rf /system/priv -app/ SnapdragonCamera rm -rf /system/priv-app/SnapdragonGallery rm -rf /system/priv-app/Snap rm -rf /system/priv-app/Trebuchet rm -rf /system/priv-app/WeatherManagerService rm – rf /system /priv-app/WeatherProvider rm -rf /system/priv-app/Tag ;; before backup) # stub ;; post backup) # stub ;; before recovery) # stub ;; after recovery) # stub ;; esac
Create a list of files to keep after a dirty flash.
list_files() { cat <<EOF addon.d/99-dirty.sh fonts/Roboto-Regular.ttf media/ audio/ ringtones/PlasticRing.ogg priv-app/BBS.apk priv-app/Gsam.apk priv-app/microG.apk priv-app/PhoneSky.apk priv-app/V4A-Magisk.apk etc/gps.conf etc /hosts EOF }
RM -RF the files not to be installed after a dirty flash (system files you removed in your mod that will be reinstalled from a dirty flash)
rm -rf / system /app/adaway.apk rm -rf /system/app/AdAway rm -rf /system/app/BasicDreams rm -rf /system/app/BookmarkProvider ……………. …………………………… rm -rf /system/priv-app/WeatherProvider rm -rf /system/priv – app/tag ;;
How to create a Flash-enabled Android zip file
We’ll use MiXplorer for this because it’s the best root is explorer and file manager for android, hands down.
- Choose first select all your folders to include in the ZIP file and select Archive.
- Confirm the creation of your archive file, give it a name and select Store.
- Your flashable ZIP file will be created, so select the ZIP file and sign it (with the MiX-Signer plugin)
- Now select TestKey to easily check it for signature errors.
- You can now flash the ZIP file – recommend to / SDcard to easily find it from custom recovery.
Final Notes
Your flashable ZIP file must be deleted after a clean flash or after deleting the / system partition and a dirty flash of your ROM The updater script will remove and add the system files you specified in your script – but leave the addon.d script alone as it will do its work without your intervention do n becomes.
After your first install, check the /system partition thoroughly to make sure everything is correct – files are being removed etc. Maybe you had a typo in a file name and it wasn’t removed, it happens.
See also: How to Get High Quality Backlinks in 2022 (7 New Strategies)
.