Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,812,054 Members 46,872 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Fix "assert failed: apply_patch_check" error

Tip us?
 
legom
Old
(Last edited by legom; 20th October 2012 at 03:24 PM.)
#1  
Junior Member - OP
Thanks Meter 25
Posts: 20
Join Date: Jul 2012
Default [GUIDE] Fix "assert failed: apply_patch_check" error

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 (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.
The Following 25 Users Say Thank You to legom For This Useful Post: [ Click to Expand ]
 
MikesDroid
Old
(Last edited by MikesDroid; 20th October 2012 at 04:31 AM.)
#2  
MikesDroid's Avatar
Senior Member
Thanks Meter 3
Posts: 253
Join Date: Sep 2007
Thanks for this. Will try now.

Worked great. Had to copy the apk and odex file.
HTC 8525 -> HTC Tilt -> HTC Tilt 2 -> HTC EVO -> Samsung Galaxy S3 -> Galaxy S4
Samsung Galaxy S4 - Stock / Rooted / Odexed
UG007 Android Stick - 1.6 Ghz, 1GB Ram, HDMI w/ FAVI Mini Keyboard
 
comminus
Old
#3  
comminus's Avatar
Senior Member
Thanks Meter 557
Posts: 616
Join Date: Jul 2011
Location: Vancouver
Good job! It's great to see the steps for Windows users!
Nexus 5 | 4.4.2 KOT49H / franco.Kernel
Nexus 4 | 4.4 KRT16S / franco.Kernel
Nexus 7 (flo) | 4.4.2 KOT49H / stock
Galaxy SII i9100 | CyanogenMod 10.2
adb / fastboot / apx drivers - Universal Naked Driver
platform tools - Windows / Linux / OSX
 
MikesDroid
Old
#4  
MikesDroid's Avatar
Senior Member
Thanks Meter 3
Posts: 253
Join Date: Sep 2007
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.
HTC 8525 -> HTC Tilt -> HTC Tilt 2 -> HTC EVO -> Samsung Galaxy S3 -> Galaxy S4
Samsung Galaxy S4 - Stock / Rooted / Odexed
UG007 Android Stick - 1.6 Ghz, 1GB Ram, HDMI w/ FAVI Mini Keyboard
 
lfc_ste
Old
#5  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Feb 2011
Great guide! Method worked perfectly on my Nexus 7 going from 4.1.2 to 4.2, thanks
 
simbin
Old
(Last edited by simbin; 13th November 2012 at 11:38 PM.)
#6  
Junior Member
Thanks Meter 1
Posts: 20
Join Date: Nov 2012
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!
 
zeroshade
Old
#7  
Junior Member
Thanks Meter 1
Posts: 2
Join Date: Dec 2010
Default 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
The Following User Says Thank You to zeroshade For This Useful Post: [ Click to Expand ]
 
damagno
Old
#8  
Junior Member
Thanks Meter 0
Posts: 1
Join Date: Nov 2012
Default 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!
 
jokkmac
Old
#9  
Junior Member
Thanks Meter 0
Posts: 1
Join Date: May 2009
Smile Nice Guide

perfect, the guide works just fine. Now finally running 4.2.
 
TheDKGunner
Old
#10  
TheDKGunner's Avatar
Junior Member
Thanks Meter 2
Posts: 7
Join Date: Jan 2011
Awesome guide... Thanks... Happily running 4.2 now aften beeing stuck at libutils.so...


Sent from my Nexus 7 using xda premium

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes