[Q] Decompiling and Recompiling an Email.apk? - Android Q&A, Help & Troubleshooting

Hi,
I'm attempting to decompile and recompile the Email.apk application on
MIUI 1.11.18 on Samsung Galaxy SII
This is the method I am using:
1) Obtain original Email.apk from phone using root explorer
2) use apktool to extract it
3) make minor changes
4) recompile using apktool
5) sign apk using signapk
6) delete email.apk from /system/apps and replace with above copy
The application installs correctly, however when I launch it, it FCs. I thought it may be something wrong with what I was modifying so I followed the above process again but missed out step 3 (so as to only decompile and recompile without changes), however I still got exactly the same issue.
Log file says:
shortMsg: java.lang.RuntimeException
longMsg: java.lang.RuntimeException: Binary XML file line #15: You must supply a layout_width attribute
Any ideas what I'm doing wrong?
Cheers,

For anyone else that might get this in the future, I seem to have resolved the issue by using the -r flag in apktool when decompiling.

Related

[Q] Decoding and re-encoding apks with APKTOOL

So I've decoded a launcherpro apk and gotten all the files inside.
I've edited them changing only some images(not .9.pngs) and some text strings for a translation.
I don't really know how to re-encode the file and sign it.
I tried using APKtools to repack but ASTRO won't let me install it saying it can't open it as an apk file.
Any help is appreciated
i cant get apktools to do anything other than decompile...
if you got it to compile your apk but dont know how to sign it, use this: http://androidforums.com/developer-101/8665-how-signing-roms.html
its what i use to sign zips and apks and it works very well and is easy. the "auto sign" or qwhatever opetion doesnt ever work for me, but option 4, manual, works fine
if you havent installed the framework-res.apk that may be why you cant compile
what you need to do is pull out the framework-res.apk and put it in you root directory then in terminal use this.
code: apktool if framework-res.apk

Problem modifying apk

Hi, i am trying to modify the classes.dex file in an apk but it is giving me problems.
if i decompile the apk and recompile it after modifying the app installs but crashes after one minute. also some functionality in the app is also lost.but when i binary edited the classes.dex file and replaced it in the apk ( i have used different methods for replacing the .dex such as direct replacing in archive and replacing in the decompiled archive) the app doesn't install and the phone or emulator reboots. i have done this with other apps and they are working fine after editing so i couldn't understand what's going wrong. please help
You should use a decompiler and achive to the java code. Than you can easily modify and recompile the app. You will need an Linux virtual machine to do this.
In linux, after you found you .apk file use this to decompile it to a .jar file. http://siis.cse.psu.edu/ded/installation.html. After that, you can use http://java.decompiler.free.fr/?q=jdgui to browse the code. With this method you will need a Linux machine and would give you the best result.
If you want to use windows, follow this tutorial http://androidorigin.blogspot.com/2011/02/dex-format-to-jar-format.html but I warn you, its likely to be faulty.
Hope this will help you.
thanks for replying
i used apktool to decompile and modify the smali code. i had even tried converting the smali code to java but no help.the problem is that the recompiled app runs only for one minute and then crashes without any error message even logcat log is not of help it just says that the process xxx has died but no err msg or exception is logged. if i replace the classes.dex with the patched one and then re-sign it it does not install and crashes the emulator but when i again decompile and then recompile the modified file it return to the same old problem of crashing. do you know how apktool packages the compiled files?
You should follow one of the tutorials posted in my last post. I did not used apktool and I don't know how it works.c the method with that decompiler will work. If you want your application signed just sign it as a normal one.
this particular apk loses about 20-30 kb in filesize on decompiling and then recompiling with apktool while this is not seen in any other apk. maybe this means that this file has some overlay data that goes missing on modifying and creats problems.7-zip is unable to show any extra data in the file.does anyone know how to add and extract overlay data on/from an apk?

Re-compile framework-res.apk (Custom Rom)

I got this figured out already, sorry about that.
Who ever thanked me, I wasn't posting a guide but a question.
I am trying from a fresh firmware base to learn from scratch but no idea how to get that framework to compile correctly.
did you install framework first?
Code:
apktool if framework-res.apk
Easy
I had problems with the apk tool and recompiling. The way I ended up doing it is:
I didnt decompile the framework-res.apk.
rename the file framework-res.apk.zip
open it with 7zip.
Extract the files you are wanting to work on
Do what ever work on the files you need done
Drag and drop the files back in the directories they go into while file is open in 7zip
Close 7zip
Rename file back to framework-res.apk
push to phone with adb
No decompile or recompile.
Hope this helps
Chadw1985 said:
I had problems with the apk tool and recompiling. The way I ended up doing it is:
I didnt decompile the framework-res.apk.
rename the file framework-res.apk.zip
open it with 7zip.
Extract the files you are wanting to work on
Do what ever work on the files you need done
Drag and drop the files back in the directories they go into while file is open in 7zip
Close 7zip
Rename file back to framework-res.apk
push to phone with adb
No decompile or recompile.
Hope this helps
Click to expand...
Click to collapse
If you just want to modify one of the 'normal' XML files or an image then that approach will work fine. The problem is he wants to edit the bool.xml file and that is contained in the 'resources.asrc' file and you need to decompile it first.
I am in the same situation although someone managed to edit the file for me and recompile it so I got there in the end, just not by doing it myself.
I followed the instructions you describe and the file never recompiled properly - or at least my device never booted with the one I recompiled
Try it like this:
1. Place APK in "place-apk-here-for-modding"
2. Choose "9" to Decompile
3. Grab resource "resources.arsc" from framework-res.apk
4. Do my edit in projects\framework-res.apk\res\values\bools.xml
5. Compile - Yes (system app) - Yes (copy files)
6. Go to "keep" folder and delete "resources.arsc" and the bools.xml file
7. Press any key
8. Either push by ADB or Root Explorer or Flash
nickiberli said:
Try it like this:
1. Place APK in "place-apk-here-for-modding"
2. Choose "9" to Decompile
3. Grab resource "resources.arsc" from framework-res.apk
4. Do my edit in projects\framework-res.apk\res\values\bools.xml
5. Compile - Yes (system app) - Yes (copy files)
6. Go to "keep" folder and delete "resources.arsc" and the bools.xml file
7. Press any key
8. Either push by ADB or Root Explorer or Flash
Click to expand...
Click to collapse
I have tried exactly like this and it didn't work for me. I downloaded lots of different APK tools and tried them all - there were comments about using older versions of apktool.jar etc. I kept getting different sizes of the output file depending on which one I used. I gave up in the end as someone edited the file for me and it was only one specific entry in bool.xmls I wanted changing. As far I could tell we were both doing exactly the same thing.
The last thing I said I was going to do was wipe the PC I was attempting to do this on. I never got round to doing it... I'd be interested to know why I could never get this working though
Andy
Give me the framework and tell me what u want to do.
I will do that for u
Btw is the framework ICS based?
Sent from my Micromax_A70 using Tapatalk 2 Beta-4
You have resigned?
Greets!

[Q] Modify java code in framework.jar

Hey everyone,
My stock rom on my phone has issues with MVNO's (mobile virtual network operator). Basically this means that my data connection only works when Roaming. This is a know issue that has already been fixed on several roms (but not on mine).
To fix this I would like to modify the source of the framework.jar file (`/system/framework/framework.jar`), more specific the file : `/com/android/internal/telephony/gsm/GsmServiceStateTracker.java`
To start I will list the steps I have take to show you where I'm stuck at the momoment:
- I have fully deodexed my stock rom, both the JAR files and the APK files in both /system/framework/ and /system/app
- I have downloaded the deodexed framework.jar file and extracted the classes.dex file from it
- I have decompiled the classes.dex file using baksmali to end up with several *.class files
- I have converted these *.class files to a .jar file using dex2jar
- I have unpacked opened this jar file using jdqui to end up with several *.java files
This is where I'm stuck, I need to figure out how to edit the java file I want and end up with a working framework.jar again that I can upload to my phone.
Am I doing this the wrong way? Any other way to resolve my issue? I hope to get some help from people who have experience in doing this...
Any help would be appreciated!
Bump, anyone?

SystemUI.apk compiling error - solved

SystemUI compiling error on stock Android 4.3 roms
This is not actually a fix just a work around to allow the compiling of the SystemUI.apk
The problem is that apktool isn’t decompiling the SystemUI.apk resources.arsc values correctly, download the attached zip and copy the enclosed values-sw720dp folder to your res folder.
This should solve the compiling error but do not replace the newly compiled resources.arsc to you phone as it could cause the SystemUI.apk to crash.
Changes to other xml or png files should work as normal if you are flashing via vrthemeing or similar methods but would suggest that after compiling your SystemUI.apk you extract the files you changed and only flash those files to your phone not the full apk
Thanks for this, it solved my compiling issues instantly.
Thank you very much

Categories

Resources