Jump to content


Photo

Deodexing/zipaligning Apk Files


  • Please log in to reply
24 replies to this topic

#1 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 10 August 2012 - 03:16 PM

So I wanted to take a stab at learning how to manually deodex system files and things like that. Anyway. I tried doing a little research on this and I've come across a couple road blocks. #1, most of the information I am digging up on XDA and the like is over a year old. #2, I came across a method that used Java files, baksmali.jar and smali.jar. I already have the Zipalign tool (not sure how to use it yet), in the Android SDK. ANYWAY, when I tried to run the commands to execute the beginning of the deodex method java -jar baksmali.jar -d c:\odex -x SystemUI.odex all I get is a bunch of errors. So I can't even move on to the next step. I hear somewhere you need to have the framework installed? Similar to how apktool works? I'm really not clear on the steps. Maybe I'm doing this the dinosaur way? I really don't know. ANY help would be great from the Droidrzr masters who know how this is done.

Thank you all in advance!

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#2 cynnar

cynnar

    Member

  • Members
  • PipPip
  • 92 posts

Posted 10 August 2012 - 04:33 PM

Not at my computer so working from memory here, and that sometimes fails me.

First download the latest smali /baksmali from

Please Login or Register to see this Hidden Content



Rename both baksmali-1.3.3.jar to baksmali.jar and smali-1.3.3.jar to smali.jar (I gathered you had done that already, but if not it just makes command line easier.)

Make a folder to put your framework (and odex) files in.
Make a folder for your apps (both apk and odex files).

You will want to start with your framework, first. Put the baksmal.jar and smali.jar in the folder with framework files.

Before you start you need to determine the API level of the rom you ate working with. If you pulled the rom from your phone then under settings -> about phone -> android version (mine is 4.0.4). Compare that to the list at

Please Login or Register to see this Hidden Content



To get your API level (API for 4.0.4 is 15)

This will look like -a 15 at cmd prompt. Be sure to put your API level in place of the 15

Open up a cmd prompt and enter in

Java -jar baksmali.jar -a 15 -x core.odex

This will make a folder called out.
Now type in the md prompt

Java -jar smali.jar out -o classes.dex

(At least I think that is how it goes)
This will put the contents of out to classes.dex
Open core.jar with something like 7zip then move classes.dex into the open 7zip window. Once classes.dex is inside core.jar then close any open 7zip windows. Delete the out folder, and classes.dex and move on to the next file.
I tend to question things I disbelieve are true. Some people cannot handle that. Sorry if you are one of those people.

#3 cynnar

cynnar

    Member

  • Members
  • PipPip
  • 92 posts

Posted 10 August 2012 - 04:34 PM

This was taken from smali / baksmali site.

Missing BOOTCLASSPATH files

The most common issue, which is almost guaranteed to happen if you're deodexing an entire build, is an error which is something like "org.jf.dexlib.Code.Analysis.ValidationException: class Lcom/google/android/gtalkservice/IChatListener; cannot be resolved."

This is caused when the odex file has an additional dependency, beyond the jars in the normal BOOTCLASSPATH. To resolve the issue, you need to find which jar contains the class mentioned in the error message, and then add that to the BOOTCLASSPATH with the -c option. You can usually guess which jar it is in from the class name, but if not, you can disassemble the framework jars and find which one has that class.

OK so the most important part of an error is this line

org.jf.dexlib.Code.Analysis.ValidationException: class Lcom/google/android/gtalkservice/IChatListener; cannot be resolved

And in that line look for this

class Lcom/google/android/gtalkservice/IChatListener;

This tells us we need to add com.google.android.gtalkservice in the command line. Use the -c : and will look like

java -jar baksmali.jar -a 15 -c :com.google.android.gtalkservice -x yourfile.odex

You can add multiple entries by using the : to separate each dependency you need. It looks like this

java -jar baksmali.jar -a 15 -c :core.jar:framework.jar:ext.jar -x yourfile.odex


I tend to question things I disbelieve are true. Some people cannot handle that. Sorry if you are one of those people.

#4 cynnar

cynnar

    Member

  • Members
  • PipPip
  • 92 posts

Posted 10 August 2012 - 04:34 PM

Apps are done the same way, but I have found it easier to put a copy of the framework files into the apps folder instead of trying to get baksmali to look in a different directory. Maybe someone else can fill that part in.

if there is a more sufficient way please chime in. Also this process was done on windows. I'm not sure of the procedure for Linux.
I tend to question things I disbelieve are true. Some people cannot handle that. Sorry if you are one of those people.

#5 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 10 August 2012 - 05:15 PM

Tomorrow, when I'm sober (LoL), I will reread this again and try to give it a go. Thank you again.

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#6 superrelaxx

superrelaxx

    Droid Master

  • Superuser
  • 921 posts
  • Twitter:jasNwa
  • LocationSeattle, Washington

Posted 10 August 2012 - 05:20 PM

Tomorrow, when I'm sober (LoL), I will reread this again and try to give it a go. Thank you again.


There's nothing more challenging than messing with the Droid with a buzz on :lol:

#7 EmericanX

EmericanX

    Developer

  • Developer
  • 1,027 posts
  • Twitter:@EmericanX
  • LocationPrince George, VA

Posted 10 August 2012 - 05:58 PM

Challenging?.... is there any other way!? Lol.

Ill throw this tip out there. Try to use one of the available tools to do a batch deodex. What you have left you will have to do manually the old fashioned way. Do some research on grep and what it is. It can be a very useful tool when you come to missing class failures!

On a side note: i think you're pushing this addiction thing to a new limit! Lol.. just started theming and now attempting a deodex! Haha I likes!

Sent from my DROID RAZR using Tapatalk 2

#8 EmericanX

EmericanX

    Developer

  • Developer
  • 1,027 posts
  • Twitter:@EmericanX
  • LocationPrince George, VA

Posted 10 August 2012 - 05:59 PM

Oh on the buzzed note use my experience and heed advice.. you will learn the importance of taking notes. You may tend to forget exactly what you did buzzed the night before. Lol

Sent from my DROID RAZR using Tapatalk 2

#9 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 05:27 AM

Oh, I've had enough drunken nights messing around with my phone just to wake up in the morning with a rom I had never seen before...and thats after I spend 15 minutes trying to remember wtf my pin pattern is to unlock the damn thing. LOL

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#10 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 05:29 AM

Challenging?.... is there any other way!? Lol. Ill throw this tip out there. Try to use one of the available tools to do a batch deodex. What you have left you will have to do manually the old fashioned way. Do some research on grep and what it is. It can be a very useful tool when you come to missing class failures! On a side note: i think you're pushing this addiction thing to a new limit! Lol.. just started theming and now attempting a deodex! Haha I likes! Sent from my DROID RAZR using Tapatalk 2


i'm working my way up to building my own ROM. But I want to get some basics out of the way. I also don't want to rely on someone releasing a deodexed source, (even though we have one), but I want to know how to do it. Not only am I an Android addict, I'm also a command line addict.

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#11 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 06:06 AM

This was taken from smali / baksmali site. Missing BOOTCLASSPATH files The most common issue, which is almost guaranteed to happen if you're deodexing an entire build, is an error which is something like "org.jf.dexlib.Code.Analysis.ValidationException: class Lcom/google/android/gtalkservice/IChatListener; cannot be resolved." This is caused when the odex file has an additional dependency, beyond the jars in the normal BOOTCLASSPATH. To resolve the issue, you need to find which jar contains the class mentioned in the error message, and then add that to the BOOTCLASSPATH with the -c option. You can usually guess which jar it is in from the class name, but if not, you can disassemble the framework jars and find which one has that class. OK so the most important part of an error is this line org.jf.dexlib.Code.Analysis.ValidationException: class Lcom/google/android/gtalkservice/IChatListener; cannot be resolved And in that line look for this class Lcom/google/android/gtalkservice/IChatListener; This tells us we need to add com.google.android.gtalkservice in the command line. Use the -c : and will look like java -jar baksmali.jar -a 15 -c :com.google.android.gtalkservice -x yourfile.odex You can add multiple entries by using the : to separate each dependency you need. It looks like this java -jar baksmali.jar -a 15 -c :core.jar:framework.jar:ext.jar -x yourfile.odex


I ran into one of these bootclass issues right away and did what you said but I still got an error? It said it could not locate com.motorola.android.widget? But that file is definitely there. Anyone know?

Please Login or Register to see this Hidden Content


That was my input

[code=auto:0]

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#12 EmericanX

EmericanX

    Developer

  • Developer
  • 1,027 posts
  • Twitter:@EmericanX
  • LocationPrince George, VA

Posted 11 August 2012 - 06:17 AM

Thats where grep comes into play. Grep the framework folder for the class youre missing then add the file that has that class to the bootclasspath

There will be times when a class is simply not there. Whether its a typo or abandoned code it happens. When that happens you'll need to baksmali with -I (uppercase i) to ignore the missing class

Sent from my DROID RAZR using Tapatalk 2

#13 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 06:26 AM

Thats where grep comes into play. Grep the framework folder for the class youre missing then add the file that has that class to the bootclasspath

There will be times when a class is simply not there. Whether its a typo or abandoned code it happens. When that happens you'll need to baksmali with -I (uppercase i) to ignore the missing class

Sent from my DROID RAZR using Tapatalk 2


I'm sorry, could you elaborate a little bit more on what grep is? and where in the baksmali command would I use the -I ? could you just write an example command with the -I in it so I would know where it goes? Thanks again

edit: also, there IS a com.motorola.widget but for some reason it says it cannot locate it? it is in the folder and within my cmd line path. I don't want to use ignore if it might cause force closes later? I just want to make sure I know when I should actually ignore something

Edited by tucstwo, 11 August 2012 - 06:32 AM.

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#14 EmericanX

EmericanX

    Developer

  • Developer
  • 1,027 posts
  • Twitter:@EmericanX
  • LocationPrince George, VA

Posted 11 August 2012 - 06:32 AM

Grep is a program used to search for a variable within files.

Grep -r "missing class name" pathtoframeworkfiles

If youre on windows youll need to do a google search to find a comparable tool.

As far as the. -i it can go anywhere..

Java -jar baksmali.jar -x -I...... so on so forth.

Sent from my DROID RAZR using Tapatalk 2

#15 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 06:40 AM

I am on windows, not linux. I tried -I, it was rejected. -a -b -c -d -f -l -m -o -p -r are my only options.

I did find wingrep too, thank you :ph34r:

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#16 EmericanX

EmericanX

    Developer

  • Developer
  • 1,027 posts
  • Twitter:@EmericanX
  • LocationPrince George, VA

Posted 11 August 2012 - 06:48 AM

I am on windows, not linux. I tried -I, it was rejected. -a -b -c -d -f -l -m -o -p -r are my only options.

I did find wingrep too, thank you


Maybe its -l... its been a while lol..

Wingrep should do it. :-) i havent used windows for about 2 years so... your guess is as good as mine.

Sent from my DROID RAZR using Tapatalk 2

#17 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 07:05 AM

I'll give that a try. -l is for "locate". hmmm. Most of these are going through with no issues, but there are a couple. I tried grep to locate that specific file, and grep didn't turn anything up. Like you said, must be abandoned?

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#18 EmericanX

EmericanX

    Developer

  • Developer
  • 1,027 posts
  • Twitter:@EmericanX
  • LocationPrince George, VA

Posted 11 August 2012 - 07:09 AM

It happens lol.

I'm buzzed most times I'm working on that stiff! You're gonna make me pull out my computer! Lol

Sent from my DROID RAZR using Tapatalk 2

#19 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 08:51 AM

yeah, I'm about 50% done with framework deodexing but there are a couple that are giving me errors. I'm not really sure where to go from here...

Specifically: android.policy.odex apache-xml.odex com.motorola.blur.library.serviceutils.odex. The first two point to a class in the "com.motorola.android.widget", but I get a cannot interface error with that. The last one (thus far) is looking for a "javax" file, which doesn't even exist as far as I can see.

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#20 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 11 August 2012 - 10:33 AM

Apps are done the same way, but I have found it easier to put a copy of the framework files into the apps folder instead of trying to get baksmali to look in a different directory. Maybe someone else can fill that part in. if there is a more sufficient way please chime in. Also this process was done on windows. I'm not sure of the procedure for Linux.



Thanks for this info. The reason I was getting errors was because of the -a 15 I wasn't putting in.
  • sublime likes this

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users