[GUIDE] Fix "assert failed: apply_patch_check" error

22 posts
Thanks Meter: 28
By legom, Junior Member on 20th October 2012, 01:29 AM
Post Reply Email Thread

This thread is a guide on how to fix the apply_patch_check error message experienced during an upgrade of the Android OS. Specifically, this will detail the steps for an upgrade of Jelly Bean from 4.1.1 to 4.1.2 on the Nexus 7 with CWM Recovery for a user of Windows. I'm sure similar steps will work for other recoveries/upgrades/devices and PC OSes.

You should only bother with this if you don't want to flash the entire system.img file to your phone, which is way easier.

Here is an example of the error message I'm talking about:
assert failed: apply_patch_check("/system/app/Chrome.apk", "819b34b66335c6faec86404d736a002b8871600", "9d6b55e63b0bf20bea433fb1ee7089f88ab73fb6")
E: Error in /sdcard/
(Status 7)
Installation aborted.
A few notes about the error:
  • This doesn't have to happen with the Chrome.apk specifically -- it could happen with any app in /system/app or .so in /system/lib.
  • Those random strings of numbers/letters are SHA-1 hashes of the apk.
    • The first one is the hash of the apk installed on your device. In my example, this happens to be the version of Chrome that comes with JB 4.1.2.
    • The second one is the expected hash of the apk that comes with JB 4.1.1.

Cause of the problem:

The reason this error occurs is because the file was somehow modified from its original state. In my case -- and most likely your case -- this was done by Titanium Backup. TB has an option to "Integrate updates of system apps into ROM", which will cause the apk in /system/app (and associated library files in /system/lib, if needed) to be overwritten with the updated apk.

  1. Download this zip file which contains the full /system/app and /system/lib directory from the JB 4.1.1 factory image. *
  2. Extract the zip to a location of your choosing on your PC.
  3. In the extracted folder, locate the .apk or .so file referenced in the error message on your device.
  4. Copy this file to your device via your preferred method (USB cable works fine). I put my file in /sdcard/Download.
  5. On your device, use a root file explorer to move the file from /sdcard/Download to /system/app (or /system/lib).
    • If you don't have a program that can do this, I use ES File Explorer. Be sure to go to Settings > Root Settings and turn on Root Explorer, Up to Root, and Mount File System.
  6. Reboot into your Recovery and try to install the update again.
  7. Repeat steps 3-6 for each subsequent file that produces an error. You will basically need to do this for each app you integrated using TB and maybe a few library files, too. **

* Future updates (above 4.1.2):

Since I won't be keeping the zip file from step #1 up-to-date, here's how to get the directories that I included in the zip for yourself:
  1. Obtain a factory image for your device's current Android version (the version you're updating from).
    • For JB 4.1.1, this file is called nakasi-jro03d-factory-e102ba72.tgz.
    • If you're reading this guide at a later date, the JB 4.1.2 file is called nakasi-jzo54k-factory-973f190e.tgz.
    • You can try your luck at the official Google site, but they seem to only provide the version you're trying to update to, not from.
  2. Extract the .tgz file somewhere on your PC.
  3. Locate the file and extract that, as well.
  4. In the folder you just extracted from the previous step, located the system.img file.
  5. Download and use a program called sgs2toext4 (Attachment 645320) to convert the system.img to system.ext4.img. ***
  6. Download and use a program called Linux Reader to open system.ext4.img.
    • Do this by going to Drives > Mount Image > Next > select your file.
    • It will then be listed under the Hard Disk Drives section in red as "Linux Ext Volume 1".
  7. Navigate to: Linux Ext Volume 1/system.
  8. Right-click on the app (or lib) directory and pick Save > Next > Output to dir of your choice.
  9. You now have the directories that were included with the zip file from Solution step #1, so just follow those steps now.

** How to avoid repeating steps:

If you'd rather not have to try to reinstall after updating only one file, just to find another file that needs updating, try this:
  1. Obtain the /system/app and /system/lib folders from the factory image and save them to your PC.
    • For the sake of this guide, let's say you save them to C:\factory_app and C:\factory_lib.
  2. Copy the /system/app and /system/lib directories from your phone to your PC.
    • For the sake of this guide, let's say you saved them to C:\phone_app and C:\phone_lib.
  3. Download the File Checksum Integrity Verifier utility from Microsoft.
  4. Start > Run > cmd
  5. fciv.exe -sha1 -xml factory_app.xml -wp C:\factory_app
  6. fciv.exe -sha1 -xml factory_app.xml -v -bp C:\phone_app
    • Don't ask me why, but you need to use -bp instead of -wp for the second command.
    • Don't forget the -v on the second command.
  7. The output of the last command will show you the list of files that are different. These are the files you need to take from C:\factory_app and put into the /system/app directory on your phone.
  8. Do the same for the lib directories (just replace all instances of "_app" with "_lib" in the previous commands).


I hope that this post helped some of you who really didn't want to have to flash the system.img or wipe your device just to update. In the future, use TB to back up the original.

I wouldn't normally bother writing up a guide like this (it took almost as long to write as it did to figure out how to do this) but I couldn't find this solution anywhere even though I saw that I wasn't the only person with the problem. Sorry for not posting this guide sooner (update has been out for a while now), but the forum required me to make a bunch of useless spam posts before I could include any links in my guide and I didn't get around to making those posts right away.

*** I would like to thank balamu96m for his guide on extracting data from the system.img file and drphrozen for making the sgs2toext4 program.
The Following 27 Users Say Thank You to legom For This Useful Post: [ View ] Gift legom Ad-Free
20th October 2012, 04:06 AM |#2  
MikesDroid's Avatar
Senior Member
Thanks Meter: 3
Thanks for this. Will try now.

Worked great. Had to copy the apk and odex file.
20th October 2012, 04:50 AM |#3  
comminus's Avatar
Senior Member
Flag Vancouver
Thanks Meter: 633
Good job! It's great to see the steps for Windows users!
20th October 2012, 05:28 AM |#4  
MikesDroid's Avatar
Senior Member
Thanks Meter: 3
Just a heads up that I simply extracted the files I needed from and on my N7 using Root Explorer, without using my PC at all.
13th November 2012, 08:29 PM |#5  
Junior Member
Thanks Meter: 0
Great guide! Method worked perfectly on my Nexus 7 going from 4.1.2 to 4.2, thanks
13th November 2012, 10:48 PM |#6  
Thanks Meter: 4
Please... is there some other way to update the files w/o installing Java on my Windoze PeeCee? I accidentally messed up my YouTube.apk with Titanium Backup... now I can't update from 4.1.2 --> 4.2 JB.

EDIT: JavaPortable FTW... updating (fingers crossed)

13th November 2012, 11:03 PM |#7  
Junior Member
Thanks Meter: 1
For anyone who flashed the 4.2 clock/keyboard already
Hey, for anyone who flashed the 4.2 clock and keyboard on their Nexus 7 already and need to roll back to do the 4.2 update, I used OP's method to make a flashable zip that puts the 4.1.2 clock and keyboard back.

Worked perfectly for my Nexus 7 to get me up and running. Hope it helps anyone!
The Following User Says Thank You to zeroshade For This Useful Post: [ View ] Gift zeroshade Ad-Free
14th November 2012, 10:40 AM |#8  
Junior Member
Thanks Meter: 0
galaxy nexus
Hi can you post a guide for galaxy nexus? Or if it is the same, can you post the link of JB factory image for galaxy nexus? Sorry, I can't find any thread for galaxy nexus, and I don't want to complete flash the stock image since I don't want to wipe my phone.

Thanks in advance!
14th November 2012, 11:28 AM |#9  
Junior Member
Flag Saarbr├╝cken
Thanks Meter: 2
Smile Nice Guide
perfect, the guide works just fine. Now finally running 4.2.
14th November 2012, 08:43 PM |#10  
TheDKGunner's Avatar
Thanks Meter: 22
Awesome guide... Thanks... Happily running 4.2 now aften beeing stuck at

Sent from my Nexus 7 using xda premium
16th November 2012, 10:56 PM |#11  
OP Junior Member
Thanks Meter: 28
Originally Posted by damagno

Hi can you post a guide for galaxy nexus? Or if it is the same, can you post the link of JB factory image for galaxy nexus? Sorry, I can't find any thread for galaxy nexus, and I don't want to complete flash the stock image since I don't want to wipe my phone.

Thanks in advance!

I don't have a Galazy Nexus, but I think the steps should be the same. Here is a link to the factory images: . It looks like they now have links for older versions, rather than just the newest images (which is how it was when I made my guide). So that's pretty sweet.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes