[Q] Services.jar changes, even simply deodexing the file prevents phone from booting - Android Software/Hacking General [Developers Only]

I am trying to make a minor change to my services.jar and so far have no been successful.
I deodexed the file with xultimate2.3.3 , extracted the classes.dex with 7zip 9.2, I used apktool 1.4.3 to "expand" the contents, made the change, repacked the dex file and put it back into services.jar and the phone cannot compelete boot. I made sure to change the permissions, owner a group to match the previous file.
I then tried using Xultimate to deodex the file and put it back on the phone and this also keeps it from booting.
I then tried using the already deodexed file from another rom (2.2.1 vs 2.2.2) and it had the same issue.
So far I have to reflash my phone with Odin every time and I am getting tired of making the same mistake over and over.
edit: Maybe I should ask - what is the appropraite way to move the file over? I am doing it by going into root explorer, deleting /system/framework/services.jar+services.odex, using adb push to put the file on the sdcard, using root explorer to move it from sdcard to /system/framework then changing the permissions in root explorer to match the previous file before finally running "chown root.root /system/framework/services.jar" from adb shell
Either my method for copying the file is bad or xultimate 2.3.3 is messing up the deodex. Any advice on another tool to use to deodex this file?

You should be using baksmali/smali to decompile/recompile classes.dex, not apktool :/

Apktool can decompile .jars too
I use it and works fine
@OP
After deodexing decompile the jar using Virtuous Ten Studio by Diamondback(Google it)
Burned from my laser torch using pencil cells

Thank you for the replies. I will try these suggestions.
As a side note I also tried to use Xultimate to deodex the file, then ran dexopt-wrapper on the output to reodex the unchanged file and the phone is stuck in a boot loop.
You can read about re-odexing files here http://themikmik.com/showthread.php...w-About-adb-odex-themes-etc&p=75225#post75225

Can you give suggestions on another tool to de-odex the services.jar file? I think xultimate is the problem. It is the only common denominator.
I forgot to add that the original services.odex is a different size and has different contents from the new services.odex created by xultimate+dexopt-wrapper

I didn't expect it to work but I took the modified/deodex services.jar from a 2.2.1 rom and put it into my 2.2.2 rom and it had the same non boot issue.

The newest version of xUltimate i could find.
Enjoy
http://www.xeudoxus.com/android/xUltimate-v2.4.2.zip

Related

[Resolved] [CLOSE THREAD] [Q] Android 2.2.1 with ODEX ROM

Hi,
I have a phone that have Android 2.2.1 with ODEX Rom.
The phone GPS has a problem, it reports the speed in knots instead m/s.
I have the solution to solve this GPS problem but I need to edit one of the classes inside the framework.odex (class location).
This is my problem:
How can I decompile the odex file and, after I make my changes, compile it again in odex format?
Hope someone can help me with this.
http://tinyurl.com/5ru2hrl
also
http://goo.gl/xB9rK
Hi,
I just found how to decompile odex files with baksmali.
But, it is possible generate the new odex file with dexopt-wrapper or something like that without use the phone?
I dont have root access in my phone because of that I must do it in my computer and use the update.zip to update my phone.
I try z4root but I think is not working with my phone.
Android 2.2.1 with ODEX ROM (Solved)
Problem solved.
I fallow this tutorial and it works just fine.
Just one thing, when I decompile the .odex file with the Baksmali I had to use the BOOTCLASSPATH.
To Baksmali and dexopt-wrapper we need to know the BOOTCLASSPATH.
In adb just type: adb shell echo $BOOTCLASSPATH

[Q] "smali" files on the I727? Can they be edited without Baksmali (Deodex)?

[Q] "smali" files on the I727? Can they be edited without Baksmali (Deodex)?
I've been looking into the coding on this phone for a while. I've made a couple of posts trying to figure out how to get Nfc enabled on this phone with no luck. So I am trying to look into it a bit further myself. I'm learning as I go, but I am trying to compare other phones files (and custom ROM files) with working Nfc with the stock ROM files on the SkyRocket to try and find clues as to which files are needed to start working on this. One thing I notice (difference) is there doesn't seem to be any "smali" files or code on the SkyRocket stock ROM. Can someone please tell me where they are located (I am rooted and use Root Explorer) on the Stock ROM or which files are used in their place?
Thanks.
**Edit**
OK, I've done a little more research and found out the "smali" code in an Odexed ROM is located in the Odexes. In order to work on them I am guessing they would need to be DeOdexed? Or is there a way to view and edit them without Baksmali?
typically bc
an odex file is renamed to class.dex and combined into the same apk
deodexing basically works likethis
every apk needs a set of instructions
thats the odex
so by removing the odex and turning it to a classes.dex
file we can remove the unwanted odex file
and speed up access to the files instructions
opens faster closes and caches faster i do beleive i could be wrong
but i know the general idea

[Q] Modifying .odex file

Is it possible to modify code in a system .odex file without de-odexing?
Here is what I've been trying, without success (Windows computer, Samsung Epic 4G Touch phone, stock ROM with 2.3.6):
On my computer, using Android Commander, I pull a .odex from /system/app to my computer. There is a corresponding .apk, but I leave that alone. I also pull the entire /system/framework folder.
On my computer, from the location containing the framework folder and the .odex file, I run "java -jar baksmali.jar --api-level 10 -d framework -x <FILE_NAME>.odex". This creates an "out" folder, with the com/android/<FILE_NAME> folder structure and the code.
I modify the code (.smali files).
I rename the original .odex file and run "java -jar smali.jar --api-level 10 out/ -o <FILE_NAME>.odex". This creates a new .odex file that, as far as I can tell, should have the updated code in it.
Using Android Commander, I push the new .odex to /system/app on my phone, change the permissions to 644, and reboot the phone.​
The changes aren't having an effect. In fact, the status bar is completely gone (the example I'm working on is a mod to the status bar in SystemUI.odex).
Any idea what I'm doing wrong?
So I'm getting the feeling that it's not possible to edit odexed apks. Is there anyway to de-odex just a single apk rather than the whole rom?
Brent212 said:
So I'm getting the feeling that it's not possible to edit odexed apks. Is there anyway to de-odex just a single apk rather than the whole rom?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=1208320
Basically, no odex can be edited and put back that easy. Wrapping and Signing ODEX style is required.
Awesome! That thread's perfect. I'm hoping I can deodex, mod the code, create a classes.dex file and put it in with the .apk, zipalign it, and just replace the existing .apk and .odex with the new .apk.
That thread (http://forum.xda-developers.com/showthread.php?t=1208320) had the answers I was looking for.
The trick was to either rename the new .odex to classes.dex and put it into the .apk, and zipalign the .apk (although I have a feeling that wasn't actually necessary), or to copy the signature from the old .odex file to the new one.
Brent212 said:
That thread (http://forum.xda-developers.com/showthread.php?t=1208320) had the answers I was looking for.
The trick was to either rename the new .odex to classes.dex and put it into the .apk, and zipalign the .apk (although I have a feeling that wasn't actually necessary), or to copy the signature from the old .odex file to the new one.
Click to expand...
Click to collapse
Odex is not dex. And vice versa. Remember that. When compiling, the result is always dex. To have odex, you need to wrap it with dexopt-wrapper within your phone.
sent from my white ray using XDA App

How to re-odex?

Normally to decompile my dex files I use smali and baksmali, how can I re-odex them?
Id like to get my service.jar re-odexed so I can try and push it to my phone via a zip update.
Sent from my MB865 using xda premium
[mini HOW-TO] Re-Odex (or create a new .odex file)
Fall of Enosis said:
Normally to decompile my dex files I use smali and baksmali, how can I re-odex them?
Id like to get my service.jar re-odexed so I can try and push it to my phone via a zip update.
Sent from my MB865 using xda premium
Click to expand...
Click to collapse
It all needs to be done on your phone, live.. with adb.
Here's how I accomplished it - I will use the services.jar in this example. Just change the file name and path to existing .odex accordingly for other files (not sure if all steps are required exactly, but it has worked for me multiple times with different jars and SysUI apk):
Requirements:
Odexed system
adb
dexopt-wrapper
Put this dexopt-wrapper file (unzip first) in /system/bin with 775 permissions:
X X X
X....X
X....X
Probably a good idea to reboot after pushing that file, if you use root explorer (like I did).
Put the deodexed services.jar (or other jar/apk file you want to make an new odex of) on your sd card.
Go to /system folder (with root explorer or equal) and mount it R/W (not sure if this is necessary - but won't hurt)
Put your USB connection to "Charge only" mode.
Go here (big props and credit to jhotmann for this) and follow steps 8-12 (I've recreated the steps with the A2's bootclasspath below).
The bootclass path is located in the /init.rc file at the root of your phone.
Connect with adb (do a adb devices check to make sure you're all good).
To create the new odex:
Code:
adb shell
su
cd /sdcard/
dexopt-wrapper services.jar new.odex /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar
I know it's a long entry for those who don't work with command lines often (like me), but double check your entry before hitting enter.
To copy the signature from the existing odex (change path to /system/app/.. if necessary):
Code:
busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc
Done! Rename new.odex (created on your /sdcard) to services.odex since that is your new signed odex file...
You can then get that on your odexed system by your choice of method (adb push, update.zip, root explorer push, etc.. - note: please know what you are doing before trying to push files with root explorer! - you cannot simply copy and paste!)
Or, if you want to deodex it right away again for some odd reason like I did (personal issues )... Take the services.jar and the new services.odex from your sdcard and put them on your computer - and open the services.jar with 7-zip (maybe winzip) and delete the classes.dex file from the 7-zip window. Now you have a fresh new set of .jar/.odex files ready for deodexing (I did this all with the SystemUI.apk last night, that's why I elaborated and re-typed this whole thing today..).
Frigging brilliant man.
Much appreciated. I'm super sick and my USB cable is at work.
Once i get it back on Wednesday, I'll work all this out. If I could thank you twice I would.
Thanks man!
Sent from my MB865 using xda premium
Fall of Enosis said:
Frigging brilliant man.
Much appreciated. I'm super sick and my USB cable is at work.
Once i get it back on Wednesday, I'll work all this out. If I could thank you twice I would.
Thanks man!
Sent from my MB865 using xda premium
Click to expand...
Click to collapse
Not a prob.
And, I updated the dexopt-wrapper link so it's easier to download - just unzip it first..
Good luck on your quest.. let me know if you catch any snags along the way - and i'll try and help you out.
Sent from my mind using XDA
Ok sooo, I think we (or most likely me) are confused on what I wanted to do. I don't want to make a NEW odex file. I need to recombine my modded classes.dex BACK with the service.jar.
Since I needed to modify some script in the services.jar I had to de-odex it so I had a classes.dex file to use baksmali with so I could modify it. Once I modded it I used smali to create the NEW MODDED classes.dex. And now I need to re-odex(bad terminology?) them to re-combine the services.jar with the classes.dex so the modded services.jar could be used on a odexed ROM.
I'm working on a de-odexed version also, but I'd like to be able to offer both
Fall of Enosis said:
Ok sooo, I think we (or most likely me) are confused on what I wanted to do. I don't want to make a NEW odex file. I need to recombine my modded classes.dex BACK with the service.jar.
Since I needed to modify some script in the services.jar I had to de-odex it so I had a classes.dex file to use baksmali with so I could modify it. Once I modded it I used smali to create the NEW MODDED classes.dex. And now I need to re-odex(bad terminology?) them to re-combine the services.jar with the classes.dex so the modded services.jar could be used on a odexed ROM.
I'm working on a de-odexed version also, but I'd like to be able to offer both
Click to expand...
Click to collapse
So, you have a deodexed services.jar (with an unedited classes.dex inside)? And, you also have an edited classes.dex (the new modded one). Just drag and drop the new modded classes.dex into the services.jar file with 7-zip to overwrite the old one.
Then I would check out the mods on a deodexed system, and provided they work, then go through the re-odexing process (separating that classes.dex from the apk and creating a new odex file) as described above to get it working on odexed systems.
Hope that helps.. Good luck!
Yes sir, you are correct. That was the first thing I tried to do was just drag and drop the modded classes.dex with 7zip, save it, however when i tried to flash the "modded" ROM it can't install the system folder because (according to Jim), when I modded copied the new classes.dex, I changed the size, and so the signature needed to be changed as well. They mismatched.
Fall of Enosis said:
Yes sir, you are correct. That was the first thing I tried to do was just drag and drop the modded classes.dex with 7zip, save it, however when i tried to flash the "modded" ROM it can't install the system folder because (according to Jim), when I modded copied the new classes.dex, I changed the size, and so the signature needed to be changed as well. They mismatched.
Click to expand...
Click to collapse
Not sure about the details of that.. I know the signatures can be tricky, but I've modded a few apks/jars similarly with no problems... when you say "can't install.." is that it wouldn't flash in recovery, or you bootlooped?
Just wouldn't flash at all.
And thanks for all your help man.
Sent from my MB865 using xda premium
I've updated the 2nd post with more detail on creating a new odex file...
Not to be a "rooster" (replace with your word of choice) or anything, but maybe this info has a place somewhere besides the general threads..?:angel: (and what is up with these new Smilies and posting reply layout?) - it just seems so hard to come by good literature on this process (which, I suppose, is a process so rarely needed though...)
So I need to perform the processes above while running in an odexed environment correct? Does this process change the deodexed APK we are running the script on to an odexed one as well as create a new .odex file for that APK? I am just confused about what the result is after running the script. For my situation I want to take 2 deodexed files (systemui and sec settings.apk) and odex them. Then push them into an odexed rom. Once I run the script above what am I left with?
Didact74 said:
So I need to perform the processes above while running in an odexed environment correct?
YES.
Does this process change the deodexed APK we are running the script on to an odexed one as well as create a new .odex file for that APK?
(Yes, it will create a new odex file that you will need to rename, but..)NO. You will need to take the classes.dex out of the deodexed apk/jar - use something like 7-zip. Unless you only edited smali, then you really only need the new odex file.
I am just confused about what the result is after running the script. For my situation I want to take 2 deodexed files (systemui and sec settings.apk) and odex them. Then push them into an odexed rom. Once I run the script above what am I left with?
Click to expand...
Click to collapse
I broke up your quote with my best answers...
As for what your're left with is a new.odex file, properly signed, if all goes well. You are going to need to do it for each of your deodexed files.
Rename them, remove the classes.dex from the deodexed files you used, and get them on your phone however you choose (I prefer zip packages and a restore.zip in case something goes wrong).
Also note that the bootclass path is different from GB to ICS.. and among different devices of course. Check init.rc file if need be. I posted the one to use for A2 ICS (think it may be the same for razr too) here: http://forum.xda-developers.com/showthread.php?t=1753659
I can't garuntee you won't have problems, but good luck... if you do you could try the dexopt-wrapper from here: http://forum.xda-developers.com/showthread.php?t=1645950 - just unzip it first obviously (but I think it's the exact same file though..)
Btw, it's all done with adb, one line at a time.. not really a script, but thank you for the idea - maybe a batch file?
Sent from my phone's mind
Great, thank you for the detailed response. Last question.
What if I have the original SystenUI.odex and SecSettings.odex files that used to be attributed to them before i deodexed them? Can I simply reuse those without having to run through the adb process?
Thanks,
Didact74 said:
Great, thank you for the detailed response. Last question.
What if I have the original SystenUI.odex and SecSettings.odex files that used to be attributed to them before i deodexed them? Can I simply reuse those without having to run through the adb process?
Thanks,
Click to expand...
Click to collapse
But, you deodexed them to edit the smali files in the classes.dex right? So, no, you will need to use the new odex files that are created from the modded deodexed files you used..
If you never edited any of the smali files, then you didn't need to deodex in the first place... you only need to deodex in order to mod the smali files - everything else in the apk can be modded as is on odexed systems.
Sent from my phone's mind
Thank you very much. Can you repost the wrapper file? Its not downloading correctly.
Didact74 said:
Thank you very much. Can you repost the wrapper file? Its not downloading correctly.
Click to expand...
Click to collapse
Updated the link in Post #2 with a zip file - you need to unzip it first then move it.
Thank you.
So I am getting an error trying to re-odex. See the attached image of the error.
Weird thing is that even though I get an error it still creates the new.odex file. I triedto go through the entire process even though I was getting errors and it just got stuck on the boot screen and never loaded. Anything in my error attached raise any flags?
Thanks,
Didact74 said:
Thank you.
So I am getting an error trying to re-odex. See the attached image of the error.
Weird thing is that even though I get an error it still creates the new.odex file. I triedto go through the entire process even though I was getting errors and it just got stuck on the boot screen and never loaded. Anything in my error attached raise any flags?
Thanks,
Click to expand...
Click to collapse
Hmmm... First thing I can think of is: are all of those framework files in the bootclass path that you used actually in your /framework folder? With our A2, in ICS there are a few extra .jar files listed that were not actually on our phone, so I had to remove those from the path...
I will try to make a new odex myself and make sure that's not a standard error message... @Fall of Enosis, you recall what it spits out?
EDIT: Shoot - forgot I'm deodexed right now... will attempt later or hear back from Fall by then..
alteredlikeness said:
Hmmm... First thing I can think of is: are all of those framework files in the bootclass path that you used actually in your /framework folder? With our A2, in ICS there are a few extra .jar files listed that were not actually on our phone, so I had to remove those from the path...
I will try to make a new odex myself and make sure that's not a standard error message... @Fall of Enosis, you recall what it spits out?
EDIT: Shoot - forgot I'm deodexed right now... will attempt later or hear back from Fall by then..
Click to expand...
Click to collapse
Yes, all .jar files listed in my bootclass were located in the framework directory.
Nevermind...my mistake. I had an issue with my files not being deodexed correctly from the start. I went back and deodexed, made the edits to res and smali then odexed using the method above again and all went well!
Thanks!

[Q] De-Odexed Framework not working

Hello all;
I have an LG p698 device, with a custom ROM (ZemDroid)(Gingerbread). Everything is working fine, but I wanted to add Arabic support to it, and for that, I need a deodexed framework.
I pulled the entire /system/framework directory, copied and modified the BOOTCLASSPATH as necessary, and used smali and baksmali 2.0.3. They reported no errors in disassembling the framework.odex file, created the "out" directory, and then using smali created the classes.dex file, which I shoved into the framework.jar file using Ark (Kubuntu 13.10).
I made a copy of the working framework.jar and framework.odex files on device, and put the new jar, and of course, deleted the odex.
wiped the dalvik cache for good measure, and rebooted.. The phone got stuck on LG logo :/ (It didn't even reach the custom splash image)
I can reboot into CWM, I can even adb into it in this state, but it won't continue starting up. Replacing original ones lets the device start normally, but my deodexed framework.jar won't :crying:
Any ideas?

Categories

Resources