• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Help? decompile/recompile framework-res.apk (Stock Deodexed)

modhatter6811

Android Enthusiast
I can't seem to decompile/recompile framework-res.apk correctly. I can decompile it and recompile it without it throwing errors but the recompiled version is smaller than the original when I make no changes to it. Is this normal? (I'm using apktool v1.5.2) Also, could someone knowledgeable confirm if this is the right process? This works fine for the SystemUI.apk,(with the added step of loading it right after framework-res) but does it work on framework-res.apk?
1. apktool if framework-res.apk
2. apktool d framework-res.apk *name
3. Make changes
4. apktool b *name
5. Extract original META-INF folder and AndroidManifest.xml from the unchanged apk, then place them into /*name/build/apk/
6. apktool b *name

*Also, if someone could point me to a tutorial or guide about making flashable zips and compiling roms that works for our cwm and phone, I will love you forever. (I got the %1 battery mod working on stock and want to make it flashable if possible.)
 
I can't seem to decompile/recompile framework-res.apk correctly. I can decompile it and recompile it without it throwing errors but the recompiled version is smaller than the original when I make no changes to it. Is this normal? (I'm using apktool v1.5.2) Also, could someone knowledgeable confirm if this is the right process? This works fine for the SystemUI.apk,(with the added step of loading it right after framework-res) but does it work on framework-res.apk?
1. apktool if framework-res.apk
2. apktool d framework-res.apk *name
3. Make changes
4. apktool b *name
5. Extract original META-INF folder and AndroidManifest.xml from the unchanged apk, then place them into /*name/build/apk/
6. apktool b *name

*Also, if someone could point me to a tutorial or guide about making flashable zips and compiling roms that works for our cwm and phone, I will love you forever. (I got the %1 battery mod working on stock and want to make it flashable if possible.)

use this and depending on what ur changing u will have to fix the errors eg: incorrect syntax, old smali code, etc...

Edit: welcome to the world of android modding :) stuff will definitely break and not work as planned its all part of the fun!
 
Thank you both so much! You guys are AWEsome! Pun slightly intended. So the resources.arsc needs to be copied from the original to the modded apk just like the META-INF and the AndroidManifest? And to clarify, the resources.arsc does not need to be copied over for a SystemUI.apk recompile, correct?
 
Thank you both so much! You guys are AWEsome! Pun slightly intended. So the resources.arsc needs to be copied from the original to the modded apk just like the META-INF and the AndroidManifest? And to clarify, the resources.arsc does not need to be copied over for a SystemUI.apk recompile, correct?

No need to worry about it with the tool i linked :D, just make sure u sign the apks
 
No need to worry about it with the tool i linked :D, just make sure u sign the apks

I tested it out, had to add the java variables, did a quick test, decompiled framework-res.apk, no issue, made NO changes and immediately recompiled back, no issues that I could see except for it saying "could not find source", and I signed it using the tool, then zip aligned -v 4 framework-res.apk, but the size is still a little off, the original is 15,515 kb, the newly recompiled but unchanged one is 15,512 kb, Why is this happening? Is it normal/ did I do something wrong?
 
No need to worry about it with the tool i linked :D, just make sure u sign the apks

I tested it out, had to add the java variables, did a quick test, decompiled framework-res.apk, no issue, made NO changes and immediately recompiled back, no issues that I could see except for it saying "could not find source", and I signed it using the tool, then zip aligned -v 4 framework-res.apk, but the size is still a little off, the original is 15,515 kb, the newly recompiled but unchanged one is 15,512 kb, Why is this happening? Is it normal/ did I do something wrong?
 
I tested it out, had to add the java variables, did a quick test, decompiled framework-res.apk, no issue, made NO changes and immediately recompiled back, no issues that I could see except for it saying "could not find source", and I signed it using the tool, then zip aligned -v 4 framework-res.apk, but the size is still a little off, the original is 15,515 kb, the newly recompiled but unchanged one is 15,512 kb, Why is this happening? Is it normal/ did I do something wrong?

which API level are you compiling with?
 
Hence a lot of issues with back porting ... lots of API dependencies which makes some things almost impossible, Google camera, Google dialer etc for some examples.

yea ive been messing around with Genymotion Android Emulator and cant install alot of stuff because of invalid API levels.

those things would be nice to have though...
 
which API level are you compiling with?

As far as I know or can tell, API 16, is there a way to change the API manually or does apktool detect it and do this automatically? I should mention, both apktool 1.5.2 and advanced apktool 2.0.0 give a smaller output when decompiling the framework or SystemUI, making no changes and recompiling. But recompiling either with advanced apktool 2.0.0 results in force close errors. recompiling with apktool 1.5.2 works perfect on either. I dont understand the data loss though. Could be optimization. Also don't know if either of you saw this, but Flashable Zip Creator 2.0 will work for our phone, its on xda somewhere. I made a flashable %1 Battery Mod. Also tested it by amending the update script, and was able to flash a test framework-res.apk, worked like a charm! Just need to point it to the update binary that was used for whatever rom you're currently on. Haven't tried it on anything other than stock though, but it should work for any rom in theory. Its fun when you open the flood gates. I might put together a batch of different flashable %1 Battery Mods. (Honestly I'd rather contribute something much greater though.) :D
 
The reason the apk comes out smaller is there's a default image compression. Typically when you try to compile an apk above your SDK version it will not install. "Unable to parse package." Will likely be your error.
 
I've tried various things over the years with back porting problematic apks from compiling against different APIs from framework, editing manifests, DPI hacks and so on... Fruitless lol. Backwards compatibility will be a thing of the past soon. It will be upgrade or die lol.
 
The reason the apk comes out smaller is there's a default image compression. Typically when you try to compile an apk above your SDK version it will not install. "Unable to parse package." Will likely be your error.

I'm not sure how my SDK version comes into play. As far as I thought, it wasnt being used by apktool. I'm running apktool 1.5.2 out of a folder on my desktop through command prompt to decompile and recompile apks. Is apktool using files from my SDK install? I dont understand how I could be compiling an apk against a version higher than my SDK? I'm not sure which SDK version I have currently but I know it supports up to Kit kat apps. Do I need to set a parameter for the api in apktool before I decompile? Very confused.
 
I'm not sure how my SDK version comes into play. As far as I thought, it wasnt being used by apktool. I'm running apktool 1.5.2 out of a folder on my desktop through command prompt to decompile and recompile apks. Is apktool using files from my SDK install? I dont understand how I could be compiling an apk against a version higher than my SDK? I'm not sure which SDK version I have currently but I know it supports up to Kit kat apps. Do I need to set a parameter for the api in apktool before I decompile? Very confused.

Just use the tool i linked :) as far as api it uses ur installed framework-res.apk for all linked resources, an app for an api higher than ur framework will not decompile
 
Just use the tool i linked :) as far as api it uses ur installed framework-res.apk for all linked resources, an app for an api higher than ur framework will not decompile

I tried using it. It wont work for me at all. Every time I decompile my framework-res.apk, then recompile with it, it causes force close errors after installing, same thing for the SystemUI.apk. The tool doesnt give any errors during decompiling or recompiling, but the resulting apks get rejected by the phone. If I use apktool 1.5.2 to decompile/recompile, making the exact same changes, the new apk will work, and so do the changes.
 
I tried using it. It wont work for me at all. Every time I decompile my framework-res.apk, then recompile with it, it causes force close errors after installing, same thing for the SystemUI.apk. The tool doesnt give any errors during decompiling or recompiling, but the resulting apks get rejected by the phone. If I use apktool 1.5.2 to decompile/recompile, making the exact same changes, the new apk will work, and so do the changes.

If u modify manifest u need to disable signature checks remove signature check from rom u still need to sign the apk as it needs a signature just doesnt matter which one as mod makes all signatures return valid:)
 
If u modify manifest u need to disable signature checks remove signature check from rom u still need to sign the apk as it needs a signature just doesnt matter which one as mod makes all signatures return valid:)

Oh! I get what you're saying. I'll have to be mindful of that. I think it was just the way I was signing using the Gui version. Doing it the manual way, I just use, apktool b SystemUI then copy and past the original manifest and META over and rebuild once more. With the gui, I was using the gui itself to sign, thus the force close errors when pushing it to the system/app with root browser.
 
Got any idea about this spacing issue? I tried editing the res/layout/status_bar.xml and reduced the padding values a lot but it seems to have no effect. I need all of these closer together so it doesnt push the clock off the bar in portrait mode. Not sure how though. Smali maybe? The hearts are the battery and the magic meter is the radio signal (legend of zelda style). Got the animations working no problem. ;-) Just need to sort this spacing issue out so it looks good.
Q5yppVj.png
 
Got any idea about this spacing issue? I tried editing the res/layout/status_bar.xml and reduced the padding values a lot but it seems to have no effect. I need all of these closer together so it doesnt push the clock off the bar in portrait mode. Not sure how though. Smali maybe? The hearts are the battery and the magic meter is the radio signal (legend of zelda style). Got the animations working no problem. ;-) Just need to sort this spacing issue out so it looks good.
Q5yppVj.png

Firstly...what size are the pngs in your drawable folder? Those look like xhdpi or larger. Keep on mind to use only drawables or resize drawable for hdpi. Or else you'll run into a lot of issues with spacing and layouts.
 
Back
Top Bottom