[Q] From apk to xml - General Questions and Answers

Hi!
I'd just formatted my computer and now I'm realizing that I forgot to backup my eclipse workspace -.- I do have the .apk backuped from my apps though, is there any way that I can "convert" the apk to xml, java, manifest etc for editing?

Apk files are zipped. Rename it to whatever.zip, unzip it and you've got everything accessible to you right there. Obviously, this doesn't include the source code
Have a Google for something called dex2jar if you want to go any further. I've never used it myself so I can't vouch for it, but it's meant to decompile .dex files into java source.
A tip for future reference (and what I do) - get a Dropbox account (if you don't have one) and make sure your default Android workspace is in that folder. I've got source code going back 2 years that I never have to worry about losing

Archer said:
Apk files are zipped. Rename it to whatever.zip, unzip it and you've got everything accessible to you right there. Obviously, this doesn't include the source code
Have a Google for something called dex2jar if you want to go any further. I've never used it myself so I can't vouch for it, but it's meant to decompile .dex files into java source.
A tip for future reference (and what I do) - get a Dropbox account (if you don't have one) and make sure your default Android workspace is in that folder. I've got source code going back 2 years that I never have to worry about losing
Click to expand...
Click to collapse
Hehe.. how do I unzip apk files? ^^
And about dropbox. I do have an account and I'd backup all the material for my developing, exept the eclipse workspace... *stupid* But yeah, that sounds smart, I'll move my current workspace to my dropbox
EDIT: Ah, I got my apk unzipped. But still... gezuuz I'm confused. I got my apps published on the market, can i still edit them and make updates? I mean, how do I open up them in eclipse so I can edit them so they appear in Package Explorer?

Related

Creating a new theme, but how to create a usable update.zip (or other easy methods)

I started a theme the other day, and I'm moving through the files pretty quickly but without context it's hard to know which graphic is which. So I want to flash or apply the current work I'm doing so I can see where things are and how they look.
Right now I'm working through a deodexed version of Froyo so all the files should be in order. Assuming that I strip out all files but the graphics, how do I create a update.zip for it or use any other method? I'm new to Android so any help would be appreciated.
I'm guessing you already have the sdk installed?
chocmatic said:
I'm guessing you already have the sdk installed?
Click to expand...
Click to collapse
Yup. SDK + Eclipse.
Emulator? no?
you can either figure out how to make them Metamorph compatible (sorry, can't give you advice on that, never done it)
Or you can put the images in the correct folder of whatever .apk they go in and make a flashable update.zip, basically replacing the existing .apk's with the full complete modded ones.
You'll need to put all the modded .apk's into a file structure that mimicks where they would be on the phone and zip that structure up with an update_script and sign the update.zip.
I would highly recommend you unzip some small flashable .zip and poke around in it to see the structure and look at the update_script.
This is a download link to a transparent tray mod I did. It replaces ONE .png but because I chose to make it a flashable .zip it requires replacing the framework-res.apk. Except for the actual .apk's you'll need to put in it, this .zip would be perfectly suitable to use as a base for your mods (and you're welcome to use it). If you did use it you would put your .apk's in the system/framework folder, delete the 3 cert files in the META folder, zip the system and META folders into "update.zip" and sign it using an autosign script.
fire away with any questions
ps, you don't need eclipse or the sdk for any of this but you will need an auto-sign script which is one of the tools in Avabox
AFAIK you couldnt use the emulator in the SDK to preview this stuff anyways because you can't get Sense running on the emulator, not to mention the emulator runs SOOOOO SLOOOOWWWWW. Even if you could get Sense running on the em I would bet you would spend less time making a nand, flashing your mods, checking them out and restoring your nand if you didn't like them than using an emulator to preview this stuff.
Award Tour said:
Yup. SDK + Eclipse.
Click to expand...
Click to collapse
Download the attached file and save folder in your tools directory. Then look at sign.txt to sign files
chocmatic said:
Download the attached file and save folder in your tools directory. Then look at sign.txt to sign files
Click to expand...
Click to collapse
Nothings attached.
nebenezer said:
you can either figure out how to make them Metamorph compatible (sorry, can't give you advice on that, never done it)
Or you can put the images in the correct folder of whatever .apk they go in and make a flashable update.zip, basically replacing the existing .apk's with the full complete modded ones.
You'll need to put all the modded .apk's into a file structure that mimicks where they would be on the phone and zip that structure up with an update_script and sign the update.zip.
I would highly recommend you unzip some small flashable .zip and poke around in it to see the structure and look at the update_script.
This is a download link to a transparent tray mod I did. It replaces ONE .png but because I chose to make it a flashable .zip it requires replacing the framework-res.apk. Except for the actual .apk's you'll need to put in it, this .zip would be perfectly suitable to use as a base for your mods (and you're welcome to use it). If you did use it you would put your .apk's in the system/framework folder, delete the 3 cert files in the META folder, zip the system and META folders into "update.zip" and sign it using an autosign script.
fire away with any questions
ps, you don't need eclipse or the sdk for any of this but you will need an auto-sign script which is one of the tools in Avabox
AFAIK you couldnt use the emulator in the SDK to preview this stuff anyways because you can't get Sense running on the emulator, not to mention the emulator runs SOOOOO SLOOOOWWWWW. Even if you could get Sense running on the em I would bet you would spend less time making a nand, flashing your mods, checking them out and restoring your nand if you didn't like them than using an emulator to preview this stuff.
Click to expand...
Click to collapse
Thanks a lot. Seeing the file, it makes sense. In your simple example you modded the framework res APK -- did you have to sign that single APK or was it taken care of when you signed the update.zip? I've modded some apps already and I know that with single APKs you have to sign them so it can be installable again. Don't know if that is needed once you sign the update.zip.
BTW, I can't wait to release this theme. It makes Sense look substantially better.
Award Tour said:
Thanks a lot. Seeing the file, it makes sense. In your simple example you modded the framework res APK -- did you have to sign that single APK or was it taken care of when you signed the update.zip? I've modded some apps already and I know that with single APKs you have to sign them so it can be installable again. Don't know if that is needed once you sign the update.zip.
BTW, I can't wait to release this theme. It makes Sense look substantially better.
Click to expand...
Click to collapse
Actually signing the .apk's is not necessary. If all you're doing is swapping out images just open the .apk's archinve with 7zip (or similar program) and drop the new .png's into the correct folder (almost always res/drawable-hdpi)
Signing the .zip makes it flashable, the .apk is usable whether you sign it into a .zip or not. Actually when you're testing stuff out I find it's much quicker to just push the modified .apk to the phone via usb, I don't make a flashable .zip until it's ready for sharing
If you push a framework file to the phone ADB REBOOT immediately.
Also, don't be surprised if some of your wallpaper gets reset to stock and your google account gets wiped out after reboot, comes with the territory
nebenezer said:
Actually signing the .apk's is not necessary. If all you're doing is swapping out images just open the .apk's archinve with 7zip (or similar program) and drop the new .png's into the correct folder (almost always res/drawable-hdpi)
Signing the .zip makes it flashable, the .apk is usable whether you sign it into a .zip or not. Actually when you're testing stuff out I find it's much quicker to just push the modified .apk to the phone via usb, I don't make a flashable .zip until it's ready for sharing
If you push a framework file to the phone ADB REBOOT immediately.
Also, don't be surprised if some of your wallpaper gets reset to stock and your google account gets wiped out after reboot, comes with the territory
Click to expand...
Click to collapse
Oh okay, I think I'd prefer using ADB too. What command would I use to push the files?
Award Tour said:
Oh okay, I think I'd prefer using ADB too. What command would I use to push the files?
Click to expand...
Click to collapse
this:
Code:
adb remount
adb pull /system/framework/framework-res.apk c:\
then I make my changes to the .apk and:
Code:
adb push c:\framework-res.apk /system/framework
adb reboot
nebenezer said:
this:
Code:
adb remount
adb pull /system/framework/framework-res.apk c:\
then I make my changes to the .apk and:
Code:
adb push c:\framework-res.apk /system/framework
adb reboot
Click to expand...
Click to collapse
Cool, just so it's clear, and I'm sorry to bug, but I'd have to pull (remove I guess)
the file before pushing the new one in?
Award Tour said:
Cool, just so it's clear, and I'm sorry to bug, but I'd have to pull (remove I guess)
the file before pushing the new one in?
Click to expand...
Click to collapse
meh, you can use another compatable copy. I always just pull it first for 2 reasons: 1) I know its the one I'm using at the moment and 2) if you're gonna be using adb it's just convenient to have it right on c:\, less typing
Award Tour said:
Oh okay, I think I'd prefer using ADB too. What command would I use to push the files?
Click to expand...
Click to collapse
adb push <filename> </target dir/targetfilename>
Read this guide, very informative on ADB
SteelH said:
Nothings attached.
Click to expand...
Click to collapse
oops my bad...it's attached now
nebenezer said:
you can either figure out how to make them Metamorph compatible (sorry, can't give you advice on that, never done it)
Or you can put the images in the correct folder of whatever .apk they go in and make a flashable update.zip, basically replacing the existing .apk's with the full complete modded ones.
You'll need to put all the modded .apk's into a file structure that mimicks where they would be on the phone and zip that structure up with an update_script and sign the update.zip.
I would highly recommend you unzip some small flashable .zip and poke around in it to see the structure and look at the update_script.
This is a download link to a transparent tray mod I did. It replaces ONE .png but because I chose to make it a flashable .zip it requires replacing the framework-res.apk. Except for the actual .apk's you'll need to put in it, this .zip would be perfectly suitable to use as a base for your mods (and you're welcome to use it). If you did use it you would put your .apk's in the system/framework folder, delete the 3 cert files in the META folder, zip the system and META folders into "update.zip" and sign it using an autosign script.
fire away with any questions
ps, you don't need eclipse or the sdk for any of this but you will need an auto-sign script which is one of the tools in Avabox
AFAIK you couldnt use the emulator in the SDK to preview this stuff anyways because you can't get Sense running on the emulator, not to mention the emulator runs SOOOOO SLOOOOWWWWW. Even if you could get Sense running on the em I would bet you would spend less time making a nand, flashing your mods, checking them out and restoring your nand if you didn't like them than using an emulator to preview this stuff.
Click to expand...
Click to collapse
This was very helpful to me as well; thanks!
Actually I just thought of a question. After you sign the file and it becomes update_signed.zip can you rename it to something else like BlahBlah.zip and have it still flash properly?
Tried twice and it failed. It would create to Meta files and not find the update script. Followed the directions but that still happened; any advice?

[Q] Editing more than just images in Phone / contacts apks

Howdy all,
I am wanting to kno if there is anything special about editing certain system apps, do they all need to be signed with the same keys. i think i read this somewhere.
cause when i decompile the phone.apk then recompile with no changes / or with changes, signed it with autosigner or APK-Manager, it just FC's on the phone and i cant make sence of the logs...
oh and i tried pushing the file with adb and x10 mod tool, tried in the emulator, still no joys.
been googling for hours... and i feel i am searching for the wrong things...
Thanks in advance
Pvy.
you can use 7zip to browse the apk as an archive and replace png's and .9.png's inside the drawable folders.
you wouldn't have to resign the apk this way, but i would recommend zip-aligning the apk after you replace the png's.
i would also make sure you know how to work with .9.png's before replacing them. not doing .9.png's correctly will break the app.
I have edited the pngs there is no prob there I can put all the images in.
I am editing the xmls and the manifest... I tried drag and drop but it seems to break the apk...
Thanks tho.
Sent from my X10i using XDA App
Go ahead and compile with apk manager, say yes to 'is it a system apk?'.
Then open the new apk with 7zip and pull out the xmls, etc. you changed.
After that open the original apk w/7zip and drag in the compiled xmls along with your images.
That should work.
So I did this,
compiled phone.apk chose system app when it asked.
drag and dropped the 3 pngs I modded, and a few xml files, and the modded androidmanifest.xml to the original
Pushed it to my phone, rebooted...
But it wont install.
It appears the signing breaks.
Pvy
AyDee said:
Go ahead and compile with apk manager, say yes to 'is it a system apk?'.
Then open the new apk with 7zip and pull out the xmls, etc. you changed.
After that open the original apk w/7zip and drag in the compiled xmls along with your images.
That should work.
Click to expand...
Click to collapse
Sent from my X10i using XDA App
Changing default image
I wondered if anyone could help me out with this
Many thanks
pvyParts said:
So I did this,
compiled phone.apk chose system app when it asked.
drag and dropped the 3 pngs I modded, and a few xml files, and the modded androidmanifest.xml to the original
Click to expand...
Click to collapse
My suggestion is after doing this add the now modded original .apk into a flashable.zip and use xRecovery/FreeXperiaRecovery to install the app.
If you don't know how to make a flashable.zip just use 7zip to replace the phone.apk in a theme update.zip and delete any other folders/.apks that you don't want being reinstalled (framework-res etc.).
Not sure if this will work because I haven't tried this after modding .xml files, but it works after I make any other changes, even changing .9.pngs.
Best of luck, hope this works.
nope that didn't work either... took me a while but once i figured out the update.zip i got it going. and still no joy.
thanks heaps guys for all your help, i think i must have to compile from source or something silly like that...
I'll keep at it and let you all kno how i go...

Need someone to compile an APK for me

Alright, so I decompiled the apk, edited the XML files I needed to. And now it won't compile. Keeps throwing java errors. Would someone be so kind to compile this for me?
This is a System APK so it needs to be compiled and signed. If you're curious or it needs extra files pulled from somewhere, it's the SystemUI.apk in the CM7 Droid nightly build 88.
Thanks!!
Here's what I need compiled:
http://mikelierman.com/SystemUI.apk.zip
0vermind said:
Alright, so I decompiled the apk, edited the XML files I needed to. And now it won't compile. Keeps throwing java errors. Would someone be so kind to compile this for me?
This is a System APK so it needs to be compiled and signed. If you're curious or it needs extra files pulled from somewhere, it's the SystemUI.apk in the CM7 Droid nightly build 88.
Thanks!!
Here's what I need compiled:
http://mikelierman.com/SystemUI.apk.zip
Click to expand...
Click to collapse
What did you use to decompile it? APK Manager from this thread?
http://forum.xda-developers.com/showthread.php?t=695701
Oh and once you compile it, you don't have to sign it because is a system app and not a regular app.
0vermind said:
Alright, so I decompiled the apk, edited the XML files I needed to. And now it won't compile. Keeps throwing java errors. Would someone be so kind to compile this for me?
This is a System APK so it needs to be compiled and signed. If you're curious or it needs extra files pulled from somewhere, it's the SystemUI.apk in the CM7 Droid nightly build 88.
Click to expand...
Click to collapse
What errors are you getting from apktool? It's going to be hard for someone else to compile an apk that has not been decoded by them and not knowing what files have been changed. Letting us know at least what .png or .xml files were modified would be a start but will work best if we could just figure out why you aren't able to build with your modifications.
The first thing I noticed from the zip you attached is that it's missing the apktool.yml file that should get created a package is decoded. Second, make sure to pull /system/framework/framework-res.apk so resources can be decoded/built properly. If you are using APK Manager, use option 10 to decode with framework-res.apk. If you are just using apktool run the command "apktool if framework-res.apk" before decoding.
mazdarider23 said:
Oh and once you compile it, you don't have to sign it because is a system app and not a regular app.
Click to expand...
Click to collapse
SystemUI.apk actually does get signed using the platform key. The easiest way to do so in my opinion is to use ZipSigner 2 on your phone. Also, once you've placed the modified SystemUI.apk into /system/app make sure it's permissions are rw-r--r--(chmod 644 /system/app/SystemUI.apk) and it's owner:group is root:root(chown 0:0 /system/app/SystemUI.apk). Next reboot to recovery, wipe dalvik-cache and cache, then reboot.
MongooseHelix said:
What errors are you getting from apktool? It's going to be hard for someone else to compile an apk that has not been decoded by them and not knowing what files have been changed. Letting us know at least what .png or .xml files were modified would be a start but will work best if we could just figure out why you aren't able to build with your modifications.
The first thing I noticed from the zip you attached is that it's missing the apktool.yml file that should get created a package is decoded. Second, make sure to pull /system/framework/framework-res.apk so resources can be decoded/built properly. If you are using APK Manager, use option 10 to decode with framework-res.apk. If you are just using apktool run the command "apktool if framework-res.apk" before decoding.
SystemUI.apk actually does get signed using the platform key. The easiest way to do so in my opinion is to use ZipSigner 2 on your phone. Also, once you've placed the modified SystemUI.apk into /system/app make sure it's permissions are rw-r--r--(chmod 644 /system/app/SystemUI.apk) and it's owner:group is root:root(chown 0:0 /system/app/SystemUI.apk). Next reboot to recovery, wipe dalvik-cache and cache, then reboot.
Click to expand...
Click to collapse
Well I'm glad you told me because little old me has been modifying system apps since the days of the nexus one and I've yet to sign one....I think is all depends on who's doing the modification...hahahaha....Good luck 0vermind on finding someone to compiling your systemui.apk!
mazdarider23 said:
Well I'm glad you told me because little old me has been modifying system apps since the days of the nexus one and I've yet to sign one....I think is all depends on who's doing the modification...hahahaha....Good luck 0vermind on finding someone to compiling your systemui.apk!
Click to expand...
Click to collapse
I'm not quite sure what to make of that comment...I certainly wasn't trying to step on your toes so I apologize if it came across that way. Just wanted to help avoid and rule out any issues that might come up. With APK Manager or by using 7zip, you can move the manifest and/or META-INF folder containing the signature from the original but to imply that system apps are not signed is incorrect.
I also think it is important that those messing with system apps understand that there are different keys used to sign apps. For anybody reading this that wants to figure out how certain packages are signed, here's a bit of an explanation. If we extract SystemUI.apk, we see a directory called META-INF. This holds the key/signature info. The key's serial number can be determined with the following command:
Code:
keytool -printcert -v -file SystemUI/META-INF/CERT.RSA | grep SerialNumber
You can check other apks/jars and noticing which have matching serial numbers, meaning they are signed with the same key...
platform key - SystemUI.apk, Settings.apk, Phone.apk, etc
shared key - Contacts.apk, UserDictionaryProvider.apk, etc
test key - Calendar.apk, DeskClock.apk, etc
google proprietary key - Vending.apk, Talk.apk, etc (including some market user apps like Maps, VoiceSearch, Docs)
MongooseHelix said:
I'm not quite sure what to make of that comment...I certainly wasn't trying to step on your toes so I apologize if it came across that way. Just wanted to help avoid and rule out any issues that might come up. With APK Manager or by using 7zip, you can move the manifest and/or META-INF folder containing the signature from the original but to imply that system apps are not signed is incorrect.
I also think it is important that those messing with system apps understand that there are different keys used to sign apps. For anybody reading this that wants to figure out how certain packages are signed, here's a bit of an explanation. If we extract SystemUI.apk, we see a directory called META-INF. This holds the key/signature info. The key's serial number can be determined with the following command:
Code:
keytool -printcert -v -file SystemUI/META-INF/CERT.RSA | grep SerialNumber
You can check other apks/jars and noticing which have matching serial numbers, meaning they are signed with the same key...
platform key - SystemUI.apk, Settings.apk, Phone.apk, etc
shared key - Contacts.apk, UserDictionaryProvider.apk, etc
test key - Calendar.apk, DeskClock.apk, etc
google proprietary key - Vending.apk, Talk.apk, etc (including some market user apps like Maps, VoiceSearch, Docs)
Click to expand...
Click to collapse
Thanks, I didn't know this! I'm glad there's people like you and mazdarider23 on this forum that know **** like this!!!

HELP with Decompiling APK (using APKTOOL)

I've looked around for some good tutorials on decompiling APKs using APKTool but haven't been able to get a few questions answered. Hoping someone can guide me with this process a bit since I'm really new at it.
A few things first: I am running CM 7.1 on a Droid Incredible (orig) and I'm also on Windows, not Linux. I'm looking to make some changes to the code of an APK and have APKtool downloaded. Questions I have so far are:
1) Do I need to use the CM 7.1 framework-res.apk file for any decompiling / /recompiling work on this 3rd party APK? Or can I do all the work without it? No one seems to have a clear answer on that and I'm not sure exactly what the framework-res.apk is for exactly.
2) After I decompile an APK and make code changes to a SMALI file, is there anything I need to do special before running the compile command?
3) After I have a newly compiled APK, what do I need to do to make this work on my phone? If I do nothing, the overall file size of the compiled APK seems much smaller than the original one that I decompiled so it seems like something is wrong. Plus it won't install. I saw one video where the newly compiled APK is renamed to .ZIP and the contents are put into the ORIGINAL APK (also renamed to .zip), overwriting all the original contents. Is this required?
4) I've also read that APKs need to be signed to install on Android. Is this correct? I found "SignApk" online which seems like it just asks you to rename your APK to app.apk and it does the signing by running a .BAT file. Is that all I have to do before installing the APK on my phone?
Would really appreciate any help on this. Or if there's a great tutorial out there on doing this, I'd be happy to read through.
Thanks for any help in advance!
I want to know these too! Hope someone helps

[Q] Pushing modified framework-res.apk?

Hi, I'm trying to modify /system/framework/framework-res.apk (on the stock Samsung Oreo ROM), more exactly config_locationProviderPackageNames in res/values/arrays.xml so that I can add org.microg.nlp as location provider. I've used the latest apktool (2.3.4) to unpack and repack the apk. I'm replacing it from TWRP and I checked that it has the same owner and rights. And after rebooting the device never finishes booting up (stuck at Samsung logo and blue led).
If I boot back to recovery and put back the original framework-res.apk the system boots fine.
What else do I need to do to make it accept the modified framework?
hey
Are you ONLY modifying the apk?
I would say there is a lot of things to check. It could be that the apk is being rejected by your handling of it. Compare both versions by 7zip lz4 without extracting. Try and use the best tools during the process.
Also more than likely you're conflicting with a service or permission that a perfect apk can't fix.
Have you tried a search in your ROM to see if any files might be associated with the result you want?
Stuff like...
com.android.location.provider.jar
com.android.location.provider.odex
com.android.location.provider.xml
Try doing all the work from your phone without any windows apps. FX explorer and symlink the apk.
Now that everything I said was probably wrong, someone else can tell you how. I'd try fx and symlink, though. It may just align the planets for you
I'm only modifying one XML resource file, but I don't know what else apktool is doing to the apk.
I'm replacing the original framework-res.apk from TWRP, by cat-ing the modified apk over the original, and I've double checked that the ownership and permissions are unchanged.
I guess I can try using another unpack/repack tool and see if it turns out any better, but I've been told that apktool is as good as it gets.
Perhaps it's because the ROM expects the apk to be signed with a certain key? I don't suppose that the key used by Samsung is available somewhere inside the ROM is it?
​
wirespot said:
I'm only modifying one XML resource file, but I don't know what else apktool is doing to the apk.
I'm replacing the original framework-res.apk from TWRP, by cat-ing the modified apk over the original, and I've double checked that the ownership and permissions are unchanged.
I guess I can try using another unpack/repack tool and see if it turns out any better, but I've been told that apktool is as good as it gets.
Perhaps it's because the ROM expects the apk to be signed with a certain key? I don't suppose that the key used by Samsung is available somewhere inside the ROM is it?
Click to expand...
Click to collapse
@wirespot - Did you ever solve the problem you described in this thread?
Not really. My last attempt was to use Runtime Resource Overlays (RROs) to override certain framework values in order to allow org.microg.nlp to run side by side with Google's service.
I will provide them below but it ultimately didn't work. The RRO apk was installed correctly, I could access the NLP settings in the system settings but the main app still could not detect or connect to the service and none of the apps that use location would work.
If anybody else wants to build or use the RRO apk I'm attaching the relevant files as well as the apk. Please note that the built apk only has "org.microg.nlp" as service in arrays.xml (but I provide an arrays.xml with all three services).
apktool.yml is provided as txt file because it wouldn't let me upload it otherwise, remove the .txt. It's used if you build the package with apktool. Remember that you'll also have to generate your own certificate and sign the package in order to install it.
Also some links that may help:
https://forum.xda-developers.com/t/guide-how-to-make-gsis-overlay-file-for-your-phone.3878974/
https://github.com/ReinhardStrauch/framework-res-overlay-sample
https://android.stackexchange.com/questions/110927/how-to-mount-system-rewritable-or-read-only-rw-ro
https://source.android.com/devices/architecture/rros#configuring-overlays
https://source.android.com/devices/automotive/hmi/car_ui/appendix
https://source.android.com/devices/automotive/hmi/car_ui/rro#step_6_dump_the_idmap
https://dzone.com/articles/customizing-android-devices-using-the-runtime-reso
https://dzone.com/articles/android-solution-install-parse-1
https://stackoverflow.com/questions...s-not-recognized-internal-or-external-command
https://github.com/lineageos4microg/android_prebuilts_prebuiltapks/issues/22
wirespot said:
I guess I can try using another unpack/repack tool and see if it turns out any better, but I've been told that apktool is as good as it gets.
Click to expand...
Click to collapse
For decompiling and building Android Oreo, I prefer version 2.3.1 of APKTool to other versions of APKTools.
wirespot said:
I'm only modifying one XML resource file, but I don't know what else apktool is doing to the apk.
...
Perhaps it's because the ROM expects the apk to be signed with a certain key? I don't suppose that the key used by Samsung is available somewhere inside the ROM is it?
Click to expand...
Click to collapse
wirespot said:
Hi, I'm trying to modify /system/framework/framework-res.apk (on the stock Samsung Oreo ROM), more exactly config_locationProviderPackageNames in res/values/arrays.xml so that I can add org.microg.nlp as location provider.
What else do I need to do to make it accept the modified framework?
Click to expand...
Click to collapse
I have not tried modifying framework-res.apk of a Samsung Android Oreo nor have I particularly tried the location services mod you are attempting (though I might get around to trying it someday) and do not know if it is valid to to accomplish what you want with it, but believe that the process should be similar to modding the file on LG Android Oreo. I shall try to guide you to how to prepare a framework-res.apk that is proper.
To answer your question about expecting a certain key. The answer to that is that that is usually the case. The signing scheme checks on system apps; however is usually not as thorough as non-system apps. framework-res.apk is also special in that it is not a running app and is instead used as a cache of system resources and system meta information. In the past, before Android Oreo, a rebuilt framework-res.apk may be made to work simply by including original signature files (META-INF) and corresponding AndroidManfest.xml file from the original framework-res.apk into the rebuilt fraemwork-res.apk file. The system would evaluate these files, and pass a check for valid platform signature. With Android Oreo, it appears that there is an additional check that was not present in the past; my best guess is that the system is checking for the V2 signing scheme signing block within the V2 Signing Scheme APK file structure. The check does not, however, thoroughly validate the signing block information.
Your mod seems rather simple and, given your previous posts, would only involve a modification to framework-res.apk "resources.arsc" member file (which contains the compiled "res/values/arrays.xml" file). If the rebuilt "resources.arsc" can be used to update ("Update" is an actual ZIP archive operation) the original framework-res.apk's member file, the updated framework-res.apk should work (and remained zip-aligned if originally zip-aligned), so long as the packed file size of the updated member file is less than or equal to the packed size of the original member file, plus up to 4 bytes depending on proximity to the next member file data if original framework-res.apk is zip-aligned as expected. If the packed modified member file(s) are larger, the original APK file structure would likely not be preserved, and a different method might have to be used. Also note that 7-Zip is not reasonable software to use for this, despite it being included with many tools on XDA to modify APK files; the software has had a history of rearranging unnecessarily zip file table entries when a change is made to an archive. Use a different tool that does not do this, such as WinRAR (I have tested version 5.61).
For normal apps, one may not copy over "resources.arsc" or resources from two different app builds and have things work correctly when the app runs; one would also need to make corresponding changes in the *.dex APK member files. framework-res.apk, not being an app the runs, has no corresponding *.dex files, and one need not worry about corrupting the relationship between the *.dex files and the resource files because none exists to corrupt.

Categories

Resources