[GUIDE] Fix "assert failed: apply_patch_check" error

Search This thread

legom

Member
Jul 4, 2012
22
28
Overview:

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:
Code:
assert failed: apply_patch_check("/system/app/Chrome.apk", "819b34b66335c6faec86404d736a002b8871600", "9d6b55e63b0bf20bea433fb1ee7089f88ab73fb6")
E: Error in /sdcard/03a4eaf95f73.signed-nakasi-JZO54K-from-JRO03D.03a4eaf9.zip
(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.


Solution:

  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 image-naksi-jro03d.zip 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 (View 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).


Summary:

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.
 
Last edited:

MikesDroid

Senior Member
Sep 4, 2007
287
3
Thanks for this. Will try now.

Worked great. Had to copy the apk and odex file.
 
Last edited:

MikesDroid

Senior Member
Sep 4, 2007
287
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.
 

simbin

Member
Nov 13, 2012
41
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)

EDIT: SUCCESS TY OP!
 
Last edited:

zeroshade

New member
Dec 6, 2010
2
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!

cantthinkofa.com/files/RestoreClockKeyboard.zip
 
  • Like
Reactions: Zomer

damagno

New member
Nov 14, 2012
1
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!
 

legom

Member
Jul 4, 2012
22
28
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: https://developers.google.com/android/nexus/images#takju . 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.
 

GallStones

Member
Jun 10, 2010
44
12
Thanks a lot man, i succeeded to "patch" my system files to update from 4.2 to 4.2.1. I first check what files didn't correspond with fciv (9 files counting both apks and odex) and then replaced them in system/app. In fact they were the apps I previously integrated with tb (learned lesson: never do it if you want to remain stock and receive OTAs). I also noticed many not-matching files in system/lib but i didn't touch them and the update went smooth the same.

Another thing: when in the OP you say it's way easier just to reflash the system.img you mean just run from bootloader "fastboot flash system system.img" (taken from the factory image as usual) or there's some other thing to do in order to fix the system partition in the right way?
 

ricky9237

Member
Jul 11, 2010
46
9
Thanks a lot man, i succeeded to "patch" my system files to update from 4.2 to 4.2.1. I first check what files didn't correspond with fciv (9 files counting both apks and odex) and then replaced them in system/app. In fact they were the apps I previously integrated with tb (learned lesson: never do it if you want to remain stock and receive OTAs). I also noticed many not-matching files in system/lib but i didn't touch them and the update went smooth the same.

Another thing: when in the OP you say it's way easier just to reflash the system.img you mean just run from bootloader "fastboot flash system system.img" (taken from the factory image as usual) or there's some other thing to do in order to fix the system partition in the right way?

Yes. I am having the same issue. I cannot update mine from 4.2 to 4.2.1. I wonder to know which original stock image you have used. Can you list a detail procedure?

Thank you very much.
Ric
 

ddd22

Senior Member
Jul 24, 2007
76
12
Southampton NY
dev/block/param

Overview:

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:
Code:
assert failed: apply_patch_check("/system/app/Chrome.apk", "819b34b66335c6faec86404d736a002b8871600", "9d6b55e63b0bf20bea433fb1ee7089f88ab73fb6")
E: Error in /sdcard/03a4eaf95f73.signed-nakasi-JZO54K-from-JRO03D.03a4eaf9.zip
(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.


Solution:

  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 image-naksi-jro03d.zip 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 (View 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).


Summary:

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.


my error 7 was generated by emmc: dev/block/mmdblk0p7 (the file is "param" any suggestions?
 

rudolf13

Member
May 8, 2012
18
0
Thanks. After searching for a lot of time, this post helped me updating my SGS3.:victory: I previously tried to integrate youtube update into rom using titanium backup.
 

legom

Member
Jul 4, 2012
22
28
Another thing: when in the OP you say it's way easier just to reflash the system.img you mean just run from bootloader "fastboot flash system system.img" (taken from the factory image as usual)
Yes, that's what I mean. The reason I didn't want to do this on my device is because I had modified some other system files that I wanted to keep the modifications for.
 

Lordkroaq

New member
Jan 31, 2013
1
0
Wow, thanks a lot OP! Your guide helped me fixing an error during the update to 4.2.2 on my Nexus 4.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 27
    Overview:

    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:
    Code:
    assert failed: apply_patch_check("/system/app/Chrome.apk", "819b34b66335c6faec86404d736a002b8871600", "9d6b55e63b0bf20bea433fb1ee7089f88ab73fb6")
    E: Error in /sdcard/03a4eaf95f73.signed-nakasi-JZO54K-from-JRO03D.03a4eaf9.zip
    (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.


    Solution:

    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 image-naksi-jro03d.zip 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 (View 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).


    Summary:

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

    cantthinkofa.com/files/RestoreClockKeyboard.zip