Proper way to modify framework.jar and android.policy.jar - General Questions and Answers

Hello - I am trying to add 'Reboot' option to Power Menu by modifying the following files - framework-res.apk, framework.jar, and android.policy.jar file. I was successfully able to add additional values to the xml file inside framework-res.apk and was able to merge my changes into the original .apk file and update in /system/framework without any issues. However, the smallest changes I make in framework.jar or android.policy.jar file breaks my system. It does not go into a Reboot Loop, but rather gives a message... Unfortunately, the <app name> has stopped working... or something like that... for almost all the apps and repeatedly.
I am on a Stock ROM of Micromax A110 (Mobistel T2). Do I need to DEODEX these .jar files first or do something else? I can't find the .odex files for these two jar files. I am not sure what I am doing wrong. Please help.

I can see some .odex files in my /system/app folder, but none in /system/framework. Is this normal? I am sure I didn't do any deodexing.

Related

[Q] Issue decompiling apk with apk manager

I have apk manager 5.02 which I can de-compile framework and recompile with out any issues.
I downloaded the stock 2.08 sense 3.5 rom and used explore2fs to extract the contents of the system.img file. From there I then put htcdialer.apk file into apk manager to decompile it and I get the following errors:
See attached log file as it is too big to put into the forum.
Any ideas why the apk file is not decompiling?
I dont hink that apkmanager can correctly decompile sense 3.5 apks, I could be wrong but i could never get them to work properly
If APK Manager and Tool cant extract even GB ROM apks is there a way of extracting and editing xml files? I tried 7zip and I can edit images but XML's do not extract correctly
Really interested to see how to edit XML files if APK Manager and APK Tool cant decode the APK's.
Found out what I was doing wrong!! When decompiling the apk file I wasn't adding the dependancy. So for example when I was decompiling the systemui.apk, I was simply using option 9 to decompile which is not right!
What you need to do is copy the systemui.apk file in to place-apk-here-for-modding
Then find the dependency framework so for example the systemui.apk depends on com.htc.recources.apk. So pull this from your phone on to the desktop and then use option 10 to decompile. It will then prompt you for the dependancy apk file. Drag that on to the command window and press enter and it decompiles! It is easy when you know how
Also when you recompile you will probably get errors...You need to take the newly created classes.dex and drop it into the original apk then push to your phone
Where can I find the dependency file??
I got the same problem when I try to Decompile any system app, like "SystemUI.apk" or "Settings.apk" ...etc
Now I understand from you that I need a dependency file, Where can I get it??
I use Samsung Galaxy SL (I9003), Rooted and Deodxed
i use samsung galaxy mini. can i use apkmanager to decompile any apk for my device......by pressing 9 directly.....? i want to decompile settings.apk....thnx in advance......

[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

Re-Compile Framework-res.apk = Bootloop

Helo, sry for noobish thread but i can's solve my problem. This method allways work for me using Zte blade. But now on Xperia Arc it doesn't.
Im trying to change somethink in framework (values) , but first i try to re-compile framework to check. And what ? i got bootloop.
Im using
ApkMultiTool 1.0.6
ApkManager 5.0.2
apktool.jar
signapk.jar
First i decompile this clean stock framework (o errors), then i try to compile (0 errors, no changes inside framework) and i got bootloop.I sign new framework and put it in my rom zip file. Then i try to make it manualy, so i run ms command line :
java -jar apktool.jar d framework-res.apk
java -jar apktool.jar b framework-res.apk
Then Sign manualy :
java -jar signapk.jar certificate.pem key.pk8 framework-res.apk signedframewok-res.apk
AND ? BOOTLOOP :////////////////////
same prob
OmenHTX said:
Helo, sry for noobish thread but i can's solve my problem. This method allways work for me using Zte blade. But now on Xperia Arc it doesn't.
Im trying to change somethink in framework (values) , but first i try to re-compile framework to check. And what ? i got bootloop.
Im using
ApkMultiTool 1.0.6
ApkManager 5.0.2
apktool.jar
signapk.jar
First i decompile this clean stock framework (o errors), then i try to compile (0 errors, no changes inside framework) and i got bootloop.I sign new framework and put it in my rom zip file. Then i try to make it manualy, so i run ms command line :
java -jar apktool.jar d framework-res.apk
java -jar apktool.jar b framework-res.apk
Then Sign manualy :
java -jar signapk.jar certificate.pem key.pk8 framework-res.apk signedframewok-res.apk
AND ? BOOTLOOP :////////////////////
Click to expand...
Click to collapse
same prob here too happening.....i cant able to change theme....!!
Before decompiling you mmust install the .apk use this command:
Cd C:/.. navigate to your framework-res.apk
Once you in the folder where it is located use this command to 1)install:
Apktool if framework-res.apk
2)Decompile:
Apktool d framework-res.apk
3)Recompile:
Apktool b framework-res
4) new .apk is in .../framework-res/dist/
I think you forgot to install the .apk
Sent from my GT-I9001 using xda app-developers app
Diablob555 said:
Before decompiling you mmust install the .apk use this command:
Cd C:/.. navigate to your framework-res.apk
Once you in the folder where it is located use this command to 1)install:
Apktool if framework-res.apk
2)Decompile:
Apktool d framework-res.apk
3)Recompile:
Apktool b framework-res
4) new .apk is in .../framework-res/dist/
I think you forgot to install the .apk
Sent from my GT-I9001 using xda app-developers app
Click to expand...
Click to collapse
If he didn't install the apk, he wouldn't be able to not even decompile correctly.
OP: I also have this problem, but from what I read, after you recompile, you need to open the new and the old apk with WinRar or 7-Zip, copy the resources.src (or something like that) from the original framework-res.apk to the modified framework-res.apk. I read that this should do the job. I'm going to try that myself later when I get home. Good luck for you.
Sent from my LT26i with Tapatalk 2
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
This simple comment of yours gave peace to my soul... THANK YOU SO MUCH!!!!!!
:laugh::laugh::laugh::laugh::victory::victory::good::good::good:
Great solution !!!!
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
sorry for a 6 month later post, but i'm having the same problem and this solution isn't making sense to me..
edit: holy **** it worked
i compile first, I just drag them into the newly compiled apk
thank you!
eris72 said:
sorry for a 6 month later post, but i'm having the same problem and this solution isn't making sense to me..
edit: holy **** it worked
i compile first, I just drag them into the newly compiled apk
thank you!
Click to expand...
Click to collapse
For me it is not working. My phone keeps looping after rebooting it.
I tried with 7zip and winrar and it is not working.
1.- Decompile with apktool1.4.2
2.- Compile with apktool1.4.3 (in this step i was editing eri.xml I need to edit this file, but also without editing this file I have the same result)
3.- Drag the META-INF and AndroidManifest.xml from the original apk to the newly created one with 7zip(also tried with winrar)
4.- push the file to the phone (system/framework)
Actually right after pushing it I get an error message saying Unfortunately, C has stopped.
What am I missing?
Did you fix permissions before pushing back to system/framework
dutchmaster18 said:
Did you fix permissions before pushing back to system/framework
Click to expand...
Click to collapse
I decompiled and compiled, both processes with the latest version and that solved my problem
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
really thank you worked for me!!!!
Helped........
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
Thank you...it helped me to overcome a problem i was unable to solve....thank u very much...:good::good::good::good::good::good:
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
Four years later and you're still saving frustrated XDA'ers.
Thank you!
Five hours of Googling and I finally have success.
Anyone know of a quicker workaround?
framework-res re/compile, push to phone
Hi have the problem with bootloop after overwrite framework-res.apk to /system/framework
use apktool2.2.2
phone note 3 with phronesis rom
I made
1.apktool if framework-res.apk (0 error)
2. decompile apktool d framework-res.apk (0 errors)
3. changed color.xml and styles.xml (only changed color text)
4. from orginal framework-res.apk drag resources.arsc to decompiled folder
5.make re-compile (apktool b framework-res) (0 errors) after this, program created new folder BUILD and DIST, in /build/apk/is META-INF, android manifest,RES folder and resources.arsc
Now i tried ( with tutorials ) drag from orginal framework-res.apk, folder META-INF, AndroidManifest.xml to BUILD folder and recompile second time (0 errors) then, from DIST folder i took framework-res.apk and overwrite to phone/system/framework and reboot = bootloop
Also trying after 1st re-compile, drag META-INF and androidmanifest.xml from orginal framework-res to newly recomplied framework-res.apk in DIST folder, again overwrite in phone/system/framework but still bootloop
before overwrite make permission rw-r--r- the same permisson of orginal framework-res.apk
then overwrited my apps example touchwiz, google play has stopped, reboot but unfortunately booloop
Any solution? ^^ thx
DrMalaN said:
framework-res re/compile, push to phone
Hi have the problem with bootloop after overwrite framework-res.apk to /system/framework
use apktool2.2.2
phone note 3 with phronesis rom
I made
1.apktool if framework-res.apk (0 error)
2. decompile apktool d framework-res.apk (0 errors)
3. changed color.xml and styles.xml (only changed color text)
4. from orginal framework-res.apk drag resources.arsc to decompiled folder
5.make re-compile (apktool b framework-res) (0 errors) after this, program created new folder BUILD and DIST, in /build/apk/is META-INF, android manifest,RES folder and resources.arsc
Now i tried ( with tutorials ) drag from orginal framework-res.apk, folder META-INF, AndroidManifest.xml to BUILD folder and recompile second time (0 errors) then, from DIST folder i took framework-res.apk and overwrite to phone/system/framework and reboot = bootloop
Also trying after 1st re-compile, drag META-INF and androidmanifest.xml from orginal framework-res to newly recomplied framework-res.apk in DIST folder, again overwrite in phone/system/framework but still bootloop
before overwrite make permission rw-r--r- the same permisson of orginal framework-res.apk
then overwrited my apps example touchwiz, google play has stopped, reboot but unfortunately booloop
Any solution? ^^ thx
Click to expand...
Click to collapse
1. apktool if framework-res.apk
2. decompile apktool d framework-res.apk
3. change color.xml and styles.xml
4. apktool b framework-res
5. drag from the NEW (dist folder) framework-res.apk this files (with zip editor): -res folder, -resources.arsc, -classes.dex (if you edited the smali too) to the OLD framework-res.apk
6. Now you can use the 'old' framework-res.apk with your phone, but now with your modifications.
I hope its help you. Sorry for the long time delay, but i just find now this therad
Make sure that you put the original manifest and meta folder back into the apk before pushing it. There's no need to resign unless you modify the manifest, all you should have to do is open the newly compiled app with winrar and add the contents of the originals folder. (Which is the manifest and meta folder)
Sent from my KYOCERA-C6745 using Tapatalk
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
THANK YOU!!!
kong said:
You shouldn't sign any system apks, instead just copy over the META-INF folder and AndroidManifest.xml from original framework-res.apk to the newly compiled one.
Click to expand...
Click to collapse
Thanks... Your suggestion worked for me :good::good:
RealWelder said:
Make sure that you put the original manifest and meta folder back into the apk before pushing it. There's no need to resign unless you modify the manifest, all you should have to do is open the newly compiled app with winrar and add the contents of the originals folder. (Which is the manifest and meta folder)
Sent from my KYOCERA-C6745 using Tapatalk
Click to expand...
Click to collapse
Well that didn't work for me , im still getting bootloop

Can't recompile settings.apk

Sorry if this is a duplicate or in the wrong place, but i cant find any solutions.
I am having trouble recompiling the settings.apk. I decompile it without problems but the apk can't recompile unless I paste in the .arsc file from the stock apk (by unziping). The problem is that when I edit the xml, it needs to make a new .arsc file since I edited xml within the layout folder.
I am using apktool and have had no problems with other apk files. This is on the Samsung galaxy player 5.0 USA.
Another note, if I decompile, put in the resources.arsc file, and recompile, the new apk file is smaller. In addition, if I unzip the recompiled apk I can edit the xml w/o a problem. This is weird because when I unzip the stock settings.apk the xml files are un-readable.
Any Ideas about what I am doing wrong?
Sorry for being a noob.
tchen510 said:
Sorry if this is a duplicate or in the wrong place, but i cant find any solutions.
I am having trouble recompiling the settings.apk. I decompile it without problems but the apk can't recompile unless I paste in the .arsc file from the stock apk (by unziping). The problem is that when I edit the xml, it needs to make a new .arsc file since I edited xml within the layout folder.
I am using apktool and have had no problems with other apk files. This is on the Samsung galaxy player 5.0 USA.
Another note, if I decompile, put in the resources.arsc file, and recompile, the new apk file is smaller. In addition, if I unzip the recompiled apk I can edit the xml w/o a problem. This is weird because when I unzip the stock settings.apk the xml files are un-readable.
Any Ideas about what I am doing wrong?
Sorry for being a noob.
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=2251719

[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