Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently stumbled upon the applypatch tool, but I couldn't find any documentation for it online. Here is the usage output (this is after typing adb shell)

shell@android:/ $ applypatch --help                                            
usage: applypatch [-b <bonus-file>] <src-file> <tgt-file> <tgt-sha1> <tgt-size> [<src-sha1>:<patch> ...]
   or  applypatch -c <file> [<sha1> ...]
   or  applypatch -s <bytes>
   or  applypatch -l

Filenames may be of the form
to specify reading from or writing to an MTD partition.

What do the command line options mean? What is MTD? What are all the sha1 hashes for?

Also, could someone with the reputation add an applypatch tag, or maybe a tools tag? Something more descriptive than what I've put.

share|improve this question
This is rather a development oriented question, I'd say? As for MTD, check Wikipedia. – Izzy Dec 29 '12 at 18:52
I wouldn't say it's development oriented. I was just looking at some code someone had written to be executed on a device and saw applypatch and was curious as to how it worked. – gsingh2011 Dec 29 '12 at 18:56
Just read the sources :-). Actually this command is really important if you suffer to broken OTA update (can be due not enough space) and your vendor supply just incremental OTA update. – pevik Mar 21 '15 at 18:01

diff and patch are Unix/Linux commands used to easily check for differences, send updates to huge files by shipping only the differences, etc. (see Wikipedia). They are mostly used in development (to update source code), but can also serve practical purposes in non-development environments.

applypatch is one of those patch-tools on Android, and used e.g. for minor updates (OTA and the like). So it is most likely not intended for the "normal end user" to deal with it directly.

share|improve this answer

The applypatch command is indeed used for OTA patching. As an example, I have the provided for my VZW SCH-I915 my case, I don't want to allow this OTA update to occur, so I wish to patch /system/build.prop to fool the device into thinking it has already been done. Within the file, there is an 'updater-script' file which details the patches. The one I sought was:

apply_patch("/system/build.prop", "-", db0889f98b62e625283e5273bf35d790532b10bd, 5934, 7a52fd5ec0d5afcbaf159c330374dfb0c5cbc159, package_extract_file("patch/system/build.prop.p"));

I extracted the appropriate patch file to my sdcard. Then, the syntax to perform this action on a secondary copy of build.prop I had made (so I could check the output before copying into /system) is altered thus:

/system/bin/applypatch "/mnt/sdcard/build.prop" "-" "db0889f98b62e625283e5273bf35d790532b10bd" "5934" 7a52fd5ec0d5afcbaf159c330374dfb0c5cbc159:/mnt/sdcard/build.prop.p

...which created the same build.prop file I would have ended up with had I allowed the OTA to proceed. I hope this helps.

share|improve this answer

Applypatch is a utility that applies a binary patch to a file. For example, on some systems, the recovery partition is created by applying a binary patch to the boot partition (the two are nearly identical and it's easier to package a patch than the entire binary during an upgrade.)

Typical usage is to run applypatch during boot time. Applypatch is run with the -c (check) option specifying storage partition, size, and hash. These arguments determine if the patch has already been applied (if the hash matches, then it's been applied.) If the patch has not been applied, then applybatch -b is executed to actually apply the patch.

Options are:

-c file [sha ...]

Confirm that the file exists and matches at least one of the SHA's. The SHA can also be encoded as part of the file name; useful for when the file name specifies a partition. See the source code for an explanation. If a file name starts with MTD: or EMMC:, then it refers to a partition instead of a regular file.

[-b bonusfile] src target target-sha1 target-size src-sha1:patchfile

Applies the patch in patchfile to the file src, creating target. target-sha1 and target-size are used to confirm the patch was successful. src and target may be storage partitions, e.g. boot and recovery. If -b is present, it specifies a zip file with extra material.

-s bytes

Exit with return code 0 if there are at least bytes space available in cache.


Display the BSD license and exit

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.