[Q] Deodex framework folder - Android Q&A, Help & Troubleshooting

I'm using official MIUI ROM right now and it's odexed. I want to deodex the framework files so I can add something. Yesterday I tried to deodex all the files in /system/framework/ folder by using command like "baksmali -c my-bootclasspath -x blabla.odex" on all of the .odex files in the folder. After finish deodexing all of them, I adb push to my system/framework/ chmod to 644 and rm all .odex files. After that I rebooted my phone and ended stuck in boot logo.
My questions:
1. Do I have to deodex the entire folder or just deodex the .jar related to bootclasspath?
2. Do I have to use "-c bootclasspath" command to deodex .jar that doesn't depends on bootclasspath like com.android.location.provider.jar?
3. Can I just deodex only my framework.jar and android.policy.jar because I only want to edit those two files?
4. Or I need to deodex the entire ROM included my apps??
Please someone help me, I'm a newbie
Sent from my Galaxy Nexus using Tapatalk 2

Related

[Q] Problem signing modified apk

Hi to all.
I have a small problem, and after struggling with it and searching on internet and xda, I haven't found a solution.
I have my Contacts.apk, which, using apktool I decompiled and edited some .xml. I have compiled again with apktool, and having my Contacts2.apk, without META-INF directory.
I tryed signing my apk with signapk.jar:
java -jar /home/aitor/Descargas/signapk.jar /home/aitor/Descargas/certificate.pem /home/aitor/Descargas/key.pk8 Contacts2.apk Contacts.apk
and when I try to install my signed Contacts.apk i get the following error:
[email protected]:~/Descargas/updateContacts/system/app$ adb install -r Contacts.apk
2717 KB/s (604449 bytes in 0.217s)
pkg: /data/local/tmp/Contacts.apk
Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]
Searching, I think it's some problem of shared uuid, and the solutions I have found is that I have to resign every apk that shares the same uuid.
Other solutions I have found say that copying the META-INF folder of the original apk to the compiled .apk might solve the problem (that means, copying the original certs). I have tryied also this, but with no result:
[email protected]:~/Descargas/updateContacts/system/app$ adb install -r Contacts.apk
2724 KB/s (584945 bytes in 0.209s)
pkg: /data/local/tmp/Contacts.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
Again, with no success.
So, my question is, is there a way of signing Contacts.apk without having to sign every apk with the same uuid? If not, how can I find every apk (in order to resign them) with the same uuid?.
Thanks for the help!
PS: I'm not sure if this should go into Android development and Hacking subforum. If so, to any mod, please, move it.
thanks in advance!
d
aitorTheRed said:
I have my Contacts.apk, which, using apktool I decompiled and edited some .xml. I have compiled again with apktool, and having my Contacts2.apk, without META-INF directory.
I tryed signing my apk with signapk.jar:
java -jar /home/aitor/Descargas/signapk.jar /home/aitor/Descargas/certificate.pem /home/aitor/Descargas/key.pk8 Contacts2.apk Contacts.apk
and when I try to install my signed Contacts.apk i get the following error:
[email protected]:~/Descargas/updateContacts/system/app$ adb install -r Contacts.apk
2717 KB/s (604449 bytes in 0.217s)
pkg: /data/local/tmp/Contacts.apk
Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]
Searching, I think it's some problem of shared uuid, and the solutions I have found is that I have to resign every apk that shares the same uuid.
Other solutions I have found say that copying the META-INF folder of the original apk to the compiled .apk might solve the problem (that means, copying the original certs).
So, my question is, is there a way of signing Contacts.apk without having to sign every apk with the same uuid? If not, how can I find every apk (in order to resign them) with the same uuid?
Click to expand...
Click to collapse
Contacts.apk is one of the system apps that is signed with the shared key. As far as I know, that does mean you will have to resign all of the apps which are also signed with that same shared key. To find out which ones are, first make a new directory to work in on your computer, open a terminal, and cd to the directory you just created. Now, with you phone attached:
Code:
adb pull /system/app/ .
for i in *; do echo $i; unzip -q $i -d tmp; keytool -printcert -v -file tmp/META-INF/CERT.RSA | grep SerialNumber; echo; rm -r tmp; done
Now examine the output for any system apps that share the same serial number as what it lists for Contacts.apk. Those will be the apps that are signed with the shared key. Now, delete the non-shared key apk files from your current folder leaving just the ones you need to resign. Also add your modified Contacts.apk that is unsigned to this folder. Then you should be able to sign them all at once, push them back to your phone, assign the correct permissions, and wipe the app caches in recovery:
Code:
mkdir signed
for i in *; do java -jar /home/aitor/Descargas/signapk.jar /home/aitor/Descargas/certificate.pem /home/aitor/Descargas/key.pk8 $i signed/$i; done
cd signed
adb remount
adb push . /system/app/
adb shell chmod 644 /system/app/*
adb reboot recovery
##in recovery, wipe cache and dalvik-cache then reboot##
For future reference, system apps should always be pushed to the phone and not not installed as it will try to install it to /data/app which you don't want. Hope that helps but post back if something isn't clear or something gives you errors.
MongooseHelix said:
Contacts.apk is one of the system apps that is signed with the shared key. As far as I know, that does mean you will have to resign all of the apps which are also signed with that same shared key. To find out which ones are, first make a new directory to work in on your computer, open a terminal, and cd to the directory you just created. Now, with you phone attached:
Code:
adb pull /system/app/ .
for i in *; do echo $i; unzip -q $i -d tmp; keytool -printcert -v -file tmp/META-INF/CERT.RSA | grep SerialNumber; echo; rm -r tmp; done
Now examine the output for any system apps that share the same serial number as what it lists for Contacts.apk. Those will be the apps that are signed with the shared key. Now, delete the non-shared key apk files from your current folder leaving just the ones you need to resign. Also add your modified Contacts.apk that is unsigned to this folder. Then you should be able to sign them all at once, push them back to your phone, assign the correct permissions, and wipe the app caches in recovery:
Code:
mkdir signed
for i in *; do java -jar /home/aitor/Descargas/signapk.jar /home/aitor/Descargas/certificate.pem /home/aitor/Descargas/key.pk8 $i signed/$i; done
cd signed
adb remount
adb push . /system/app/
adb shell chmod 644 /system/app/*
adb reboot recovery
##in recovery, wipe cache and dalvik-cache then reboot##
For future reference, system apps should always be pushed to the phone and not not installed as it will try to install it to /data/app which you don't want. Hope that helps but post back if something isn't clear or something gives you errors.
Click to expand...
Click to collapse
Thanks! I will try it asap and give some feedback about the results!
aitorTheRed said:
Thanks! I will try it asap and give some feedback about the results!
Click to expand...
Click to collapse
Something I hadn't thought of that you might want to try before taking the more extreme approach I described above...
Use 7zip to open both the original and modified Contacts.apk. Take the META-INF folder from the original(along with AndroidManifest.xml if it wasn't modified) and copy/place in the modified version. It will now contain the original signature and might work now.
Code:
adb remount
adb push built/Contacts_modified.apk /system/app/Contacts.apk
adb shell chmod 644 /system/app/Contacts.apk
adb reboot recovery
##in recovery, wipe cache and dalvik-cache then reboot##
Make sure you have a backup copy of the original Contacts.apk somewhere in case you need to restore it.
And? Did this method work? I am asking, because when I try to re-install the HtcFacebook.apk (which is also a system app) I get the same error:
INSTALL_PARSE_FAILED_NO_CERTIFICATES
But before I start messing with my /system/app folder I would like to know, if it worked in your case. Thanks in advance!
I had a similar problem with another Android core app (Stk.apk). I tried the hack suggested by MongooseHelix - replacing META-INF and the manifest - and it worked
MongooseHelix said:
Something I hadn't thought of that you might want to try before taking the more extreme approach I described above...
Use 7zip to open both the original and modified Contacts.apk. Take the META-INF folder from the original(along with AndroidManifest.xml if it wasn't modified) and copy/place in the modified version. It will now contain the original signature and might work now.
Code:
adb remount
adb push built/Contacts_modified.apk /system/app/Contacts.apk
adb shell chmod 644 /system/app/Contacts.apk
adb reboot recovery
##in recovery, wipe cache and dalvik-cache then reboot##
Make sure you have a backup copy of the original Contacts.apk somewhere in case you need to restore it.
Click to expand...
Click to collapse
Yes. This method works if AndroidManifest.xml has not been modified.
If AndroidManifest.xml was modified, the signing process becomes complicated. Can I resign the whole ROM using the signapk? This menas: do not use Samsung signature anymore.
.
SunnyOK said:
Yes. This method works if AndroidManifest.xml has not been modified.
If AndroidManifest.xml was modified, the signing process becomes complicated. Can I resign the whole ROM using the signapk? This menas: do not use Samsung signature anymore.
Click to expand...
Click to collapse
Another trick that usually works is changing the install location in the manifest. Then resign it.

[Q] Deodex-ing SystemUI

I'm having some problems with deodexing SystemUI
I have honestly no idea what these bootclasspath-things are.
So I need some help to find the right bootclasspath
When I try:
Code:
baksmali -x SystemUI.odex
it comes that "Error occured while loading boot class path files."
Code:
baksmali -c <what-shall-i-write-here?> -x SystemUI.odex
Bump?
Sent from my GT-I9100 using XDA Premium App
Buuuuuuuuuuuuuuuuuuuuuuump..
specifically I don't know what bootclasspath files are used, but it doesn't matter.
it doesn't matter if you put all the contents from the framework folder into your working directory and then baksmali will "find" them...if they are in the working directory.
all you need to do is
Code:
baksmali -x SystemUI.odex

[Q] Is it possible to deodex a framework.odex and odex it with baksmali/smali?

For some reason I need to deodex a framework.odex, that is the /system/framework/framework.odex.
Look at this, there are 2 files list in /system/framework/:
[email protected]:~/experiement# adb -d shell ls /system/framework/frame*
/system/framework/framework.odex
/system/framework/framework.jar
using baksmali, I need to specify -d <Dir>, where <DIR> is a dir containing framework.jar etc.
Obviously this is a recursive loop.
So Is it possible to deodex framework.odex?
BTW, below are my commands to deodex a framework.odex, and its output.
[email protected]:~/experiement# baksmali -a 15 -x framework.odex -d .
#make some changes to some file in out dir and smali it
[email protected]:~/experiement# smali -a 15 -x -o framework.odex.m out/
[email protected]:~/experiement# file framework.odex*
framework.odex: Dalvik dex file (optimized for host) version 036
framework.odex.m: Dalvik dex file version 036
It sound that framework.odex is an odex file while framework.odx.m is not an odex file.
So If I push framework.odex.m to /system/framework/framework.odex, the phone will not boot, I believe.
Is there a way to turn out dir to a new framework.odex file and push it to /system/framework/framework.odex, and the phone will boot OK?
whogiawho said:
It sound that framework.odex is an odex file while framework.odx.m is not an odex file.
So If I push framework.odex.m to /system/framework/framework.odex, the phone will not boot, I believe.
Click to expand...
Click to collapse
I bricked my phone that way.
The smali will not create an odex file, its a dex file.
(Yet, the baksmali will actually read an odex, strange enough.)
You should copy the dex as classes.dex one into the original jar (with 7zip).
If you want the odex you need to "dexopt-wrapper" this new jar (with the classes.dex inside).
I dont think you need the odex for your new jar to work, the classes.dex inside the new framework.jar should suffice. As long as you replace the original framework.jar with with your new jar and delete the original framework.odex. (which no longer fits your new framework.jar anyhow)
Creating the new ODEX on top is optional.
In fact I did all that and it still bricked my phone

[DEV HELP] make an apk execute a shell command when opening

Hey, i have recently been working on my own theming system, im not that good with .apk files yet, i know XML and am learning smali, but i am clueless with building..
so basically this is how my theming system works, i have a directory called /system/etc/SPRtools containing an ORS(openrecoveryscript) and a flashable .zip file called theme.zip, at the moment to start the theming system i have made a bin file that executes the following
#!/system/bin/sh
cp /system/etc/ORS /cache/recovery/openrecoveryscript
cp /system/etc/theme.zip /sdcard/
reboot recovery
now how would i go about making a .apk file that you click on and does this?
or even give me a hand on integrating it in SecSettings.apk??
oh and i also have an init.d script that deletes the copied theme.zip for the sdcard!
thanks guys!!

Deodex lollipop system app? Having trouble.

So I have the latest smali and baksmali jar files from google. I have everything setup correctly. Baksmali and smali are in a folder named smali on my C: directory. SystemUI.odex is also in that file. I also have my entire framework directory from my ROM on the root of my c drive. I'm trying to deodex SystemUI.odex. when I run this command in command prompt : "java -jar baksmali.jar -d C:\framework -x SystemUI.odex" I get an error stating that systemUI.odex is not an apk, dex or odex file....... Any idea what the issue is?
Sent from my Nexus 5 using xda premium

Categories

Resources