[Help] Recompiling Phone.apk from source code - Android Software/Hacking General [Developers Only]

Hi all,
i am trying to recompile the Phone.apk for our phone of CM7 by using the mmm command (without changing the existing code).
After I replace the Phone.apk on the phone using adb push , the phone starts to FCs ( I have set the proper permissions as well).
I tried to reboot it but still the FCs are present and the phone application does not work.
I am able to recompile the complete ROM and flash it through Recovery successfully.
I need to mention that the Phone.apk created with mmm is around 2MB whereas the one included in the recompiled rom is around 1.1 MB.
Does anyone have any idea what I an doing wrong ? Is it logical that the two apks have different sizes?
Thanks
Chris

Related

Signing framework-res.apk

i got a question for someone obviously brighter than me.... i made some higher level mod's to my framework-res.apk utilizing apkmanager... i was able to decompile and compile with no errors but i need it signed so i can push it .... i used apkmanagers signing utiliy but i get fc's like crazy.. i got the same result using android kitchen signing utility... i can copy over the res folder into another apk but its the resources.arsc i need too and when i copy it over i get a bootloop aswell..
before you respond... i need this file to be able to be pushed .. i know i can create and update.zip and sign the zip but that isnt going to work for what i'm trying to do
any help would be greatly appreciated
Copying resources.arsc to original apk and using update.zip gives me bootloop aswell. Just not funny, I can't flash my phone to test every possible combination.
Too bad you can't use AVD to flash roms... hmmm

modding .xml in framework-res.apk with apktool?

i know there are hunderds of threads about this, but none of them helped me and niether of them describes my situation.
i had to change some values in bools.xml in framework-res.apk of a deodexed cm7.2 rom. so, i decompiled and recompiled using apktool and tried the folowing things (in all cases i remembered to chmod to 664):
- pushed the compiled file without signing. Boot loops.
- wiped dalvik cache. still boot loops.
- signed the compiled file. IT BOOTED! but all system apps fc. And i see a blank status bar. clearing dalvik cache doesnt help.
- copied the compiled resources.asec to original apk with winrar. NO FCs this time. still a blank status bar. Rotating the phone freezes the system instantly. but even if you dont rotate, system soon freezes, within 30 secs. logcat shows repeating messages of "cpu may be pegged. trying again". (no i havent overclocked).
how do u guys mod the frameworkres successfully?
Well, I don't know exactly what the problem you're having is since it may depend on the type of mod you're doing but..
I decompile framework-res.apk with apktool, make my changes and recompile. Then I use 7zip to copy the res folder from the new apk to the old one (just open both and drag across). Next, I extract resources.arsc from the new apk and add it to the old one, making sure to use 'store' compression. If resources.arsc is compressed at all, it causes problems.
So the original framework-res.apk now has a new res folder and resources.arsc at the right compression ratios. If you sign the new apk file, you have to make sure all the other system apps are signed the same way and it's just more trouble than it's worth.
Then I reboot into recovery, mount the system and push straight to the framework folder. I used to do this while the phone was running normally but I'd get all kinds of odd bugs if I made any change to anything other than a drawable. I'd get strange FC's, I'd lose wifi connection, all kinds of things.
And that's about it. As long as the changes I'm making don't stop the phone from working properly anyway, the above works perfectly every time.
Sent from my U20i using xda premium
arnab321 said:
(in all cases i remembered to chmod to 664):
Click to expand...
Click to collapse
Did you made a typo, or did you really have set the permissions to 664?
Its 644.
brainmaster said:
Did you made a typo, or did you really have set the permissions to 664?
Its 644.
Click to expand...
Click to collapse
that was actually a typo, and once i also accidentally made a typo on adb, but it still boots fine. i dont think giving extra permissions will screw things up.
the problem "cpu may be pegged" is rom/kernel related, because it is still there after a fresh install... sometimes it happens, sometimes not.
but i dunno anything about the blank status bar... i was trying to set "has_soft_keys" to true, to use tablet tweaks on my phone, does that cause a blank statusbar? anyone else got the same problem?
Wait, why are you using framework-res.apk for that? I think you need to change local.prop in /data to do this.
Have you actually got the line "has_soft_keys" already in the bools.xml?
Ticklefish said:
Wait, why are you using framework-res.apk for that? I think you need to change local.prop in /data to do this.
Have you actually got the line "has_soft_keys" already in the bools.xml?
Click to expand...
Click to collapse
yes it had that line, and setting it to true does bring the softkeys stuff in tablet tweaks menu. But the status bar always stays empty, nothing on it.
what needs to be changed in local.prop? There's nothing related to softkeys there on my phone.
umm, my ROM had the center clock mod on status bar, is that an issue?
Sent from my LG-P500
edit:
yes it was due to the center clock. tried anoher rom and i got the softkeys just by modding the bools.xml
First of all never sign system apps.
try using apk manager(I know it uses apk tool to do these operations) so try to set compression level to zero and heap size to 512.
I think above solutions should solve your problem but revert if u face any problem.
Sent from my Micromax_A70 using Tapatalk

[Q] ICS contacts.apk modifications will be shutdown the dial.

Hello every one!
I have modified the theme to make a contacts.apk.
here is working list
A. Compile contacts.apk
B. System / app in the Flash
C. I modified the theme contacts.apk was perfect. But to force a shutdown phone.apk
Using APK-MANAGER 5.02, and I only "Value / color.xml" modified
For other systems, applications will work fine without any problems
"contacts.apk" by modifying the "phone.apk" Do not run
Please help me alone!
what in the hell did i just read

[Q] question about (de)compile...

I'm getting this issue:
I got Settings.apk and framework.apk from a rom, then i opened apktool and
1) imported fw: apktool if framework.apk
2) decompiled apk: apktool d Settings.apk
3)edited a string in a xml
4) rebuilt all: apktool b Settings Settings.apk
5)pushed it into system/app
6) fix permissions and reboot.
Settings now should work, but it doesnt. Can somebody tell me where i do a mistake?
Thank you
(I used win8, but i could use macos or ubuntu as well)
sign it first
ej8989 said:
sign it first
Click to expand...
Click to collapse
I did it. same result. maybe the application I used is not good (Auto-Sign v0.65). what application i've to use?
I didnt write it before, however the rom is on 4.2.1 (cyanogen 10.1)
put your re-complied apk to your phone's sd card and use zipsigner2 from playstore to sign it.
ej8989 said:
put your re-complied apk to your phone's sd card and use zipsigner2 from playstore to sign it.
Click to expand...
Click to collapse
Nothing. Maybe this is not good for 4.2.1? (I've used it lots of times with 4.1)
Well, apktool is using smali/baksmali to compile/decompile classes.dex/apk_name.odex file.
The problem can occur when you use different baksmali version when you decompile and also not the right version to compile (as the system expects it to be). You can also experience issues if the apk is not zipaligned properly (check down who to do that)
apktool has the smali/baksmali code inside it so you will need to get the newest version for it for JB for example.
You can check why the status bar is not there when you monitor the logcat and look for DEX related logs in the beginning.
You can also use smali/baksmali on your own: http://code.google.com/p/smali/wiki/DeodexInstructions
and just place the generated classes.dex in the apk
then zipalign -f 4 filein.apk fileout.apk (http://developer.android.com/tools/help/zipalign.html)
then push back fileout.apk (sytemui.apk in your case)
Sent from my Galaxy Nexus using xda premium

[SOLVED] APK/smali editing question/help

First I want to say thanks in advance for anyone who might be able to help - my guess is I'm missing something stupid, but I'm having some issues working it out. I've recently ported a Sense 4.1 ROM from a VilleC2 RUU to my device (HTC Holiday/Vivid) and have been working out some bugs. One of them was readding the hardware menu button functionality in Rosie. After some battling, I added the proper methods in the .smali, flashed it, menu button worked. Awesome, or so I thought. I baked the new Rosie.apk into the ROM, full wiped, flashed, and Rosie/Sense crash immediately after setup. So I full wiped, flashed the previous version of the ROM and all was well. Flashed the fixed Rosie.apk and all was even better. My question is what am I doing that the new Rosie.apk won't install properly from a full wipe/flash? Here are all the things I've tried that work/don't work...
First, what works..
Using VTS - if I make the edits and sign with either a test key, or the original key, the fix is applied as long as it's installed on top of an already working/stock Rosie (whether it's a dirty flash from a full build, or a standalone recovery flashable package)
What doesn't work..
Baking the "fixed" apk into the ROM and flashing after a full wipe. This results in Rosie/Sense crashing immediately after setup.
Trying to flash/install the fixed apk over the flashed ROM that had it baked in
I've tried using APKTool to decompile/edit/recompile, both using the newly outputted apk, as well as replacing classes.dex in the original .apk with the newly edited one, and this just results in Rosie crashing (whether it's baked in or installed on top of a working Rosie)
I've also tried the above with the outputted classes.dex from VTS (injecting into the original Rosie.apk), which also results in Rosie crashing.
Fixing permissions and/or wiping cache and dalvik doesn't fix the crashes.
While I am relatively new at this, I somewhat know my way around .apks and have been editing them without (too many) issues for a while now, but this one has me stumped...What am I doing wrong???
Edit: Maybe this was better in Chef Central > Android? If it needs to be moved, please do
Edit 2: I was just being stupid - while trying to not break the signature I was continually breaking the signature. This thread can be closed. Method used to get it to flash correctly with the ROM (I guess it helps to know how to PROPERLY use the tools available to you):
Decompile with apktool
Make edits
Build with apktool
Put META-INF folder and AndroidManifest.xml frin the original apk into /build/apk/
Build with apktool again
Use apk from /dist/

Categories

Resources