Creating Android OTA Packages with User Data Wipe

Typically, Android OTA (Over-The-Air) upgrades preserve user data. However, if you need to create an update that clears user data, you can add the --wipe_user_data parameter during package creation.

Creating a Differential Update Package with Data Wipe

To generate a differential OTA package that wipes user data, use the following command structure:

./out/soong/host/linux-x86/bin/ota_from_target_files --wipe_user_data -v --block -p out/host/linux-x86/ -i old_build.zip new_build.zip update_package.zip

Creating a Full Update Package with Data Wipe

  1. First, compile the target files package using the make otapackage command. The generated file will be located at out/target/product/device_name/obj/PACKAGING/target_files_intermediates/full_device_name-target_files-build_version.zip. This file serves as the base for creating both differential and full update packages.
  2. Use the following command to generate a full OTA package that wipes user data:
./out/soong/host/linux-x86/bin/ota_from_target_files --wipe_user_data out/target/product/device_name/obj/PACKAGING/target_files_intermediates/full_device_name-target_files-build_version.zip full_update.zip

Troubleshooting Package Creation Issues

If you encounter the following error during package creation:

Cannot generate downgradable full OTAs

You'll need to modify the ota_from_target_files.py script. The error typically occurs when atetmpting to create a full OTA package with user data wipe that can also be downgraded.

Script Modification

Locate and edit the file at build/tools/releasetools/ota_from_target_files.py. Find the section that checks for downgradable full OTAs and modify it as follows:

if OPTIONS.wipe_user_data:
    if not OPTIONS.vabc_downgrade:
      logger.info("Detected downgrade/datawipe OTA."
                  "When wiping userdata, VABC OTA makes the user "
                  "wait in recovery mode for merge to finish. Disable VABC by "
                  "default. If you really want to do VABC downgrade, pass "
                  "--vabc_downgrade")
      OPTIONS.disable_vabc = True
    # We should only allow downgrading incrementals (as opposed to full).
    # Otherwise the device may go back from arbitrary build with this full
    # OTA package.
    # if OPTIONS.incremental_source is None:
      # raise ValueError("Cannot generate downgradable full OTAs")

It's recommended to use a text editor like vim to make these modifications.

Tags: Android OTA update packages system upgrades data wipe firmware updates

Posted on Tue, 02 Jun 2026 17:46:08 +0000 by nigel_belanger