Trying to change status_bar.xml but aapt keeps inserting zero bytes? - Android Software/Hacking General [Developers Only]

Hi,
I was trying to modify status_bar.xml in framework-res.apk. I downloaded the source from git, and started changing the xml files. Then I used aapt to package them into an apk. However, when I move the binary status_bar.xml to some other framework-res.apk that worked before, I get stuck in a boot loop. I compared both status_bar.xml's in a hex editor, and it seems aapt inserted a lot of zero bytes (see screenshot, left the new one, right is the working one), at first I thought it might have something to do with UTF-8, but setting another encoding didn't do anything. Anyone know what I'm doing wrong here?

Yeah, you're right, file on the right was built using new encoding introduced in Froyo and it can't work on Android <= 2.1 . It's used when you set minSdkVersion to 8.
But you said, that this one is ok and that normal encoding ("normal", cause it was here for last 2 years) on the left isn't working. I don't really know, why.

Brut.all said:
Yeah, you're right, file on the right was built using new encoding introduced in Froyo and it can't work on Android <= 2.1 . It's used when you set minSdkVersion to 8.
But you said, that this one is ok and that normal encoding ("normal", cause it was here for last 2 years) on the left isn't working. I don't really know, why.
Click to expand...
Click to collapse
The status_bar.xml on the right is from this AOSP Desire rom. I just tried to built it with minSdkVersion set to 8 and it seems to work. Thanks for the help!

Got one more question on the subject. It's working now, in the sense that I edit the XML file, use aapt to build an apk, then move the binary xml to the original framework-res.apk. When I try to sign the homebuilt framework-res.apk and boot my phone it goes into a boot loop. Is there any way that you can replace framework-res.apk without resigning all other apps?

I think you must install it through an update.zip file.

And right you are. Thank you very much

And here I am again. It does seem to work, signing it and putting it into an update.zip, however, when I boot my phone, it gets to the sim unlock screen, and it starts FCing. Logcat has the following messages:
Code:
W/PackageManager( 400): Unknown permission android.permission.VIBRATE in package com.google.android.gsf
W/PackageManager( 400): Unknown permission android.permission.WAKE_LOCK in package com.google.android.gsf
W/PackageManager( 400): Unknown permission android.permission.WRITE_CONTACTS in package com.google.android.gsf
Basically it shows these messages for all applications, for all permissions. The weird thing is, I tried this yesteray, right after your post and it worked fine. But now it doesn't work anymore. This is, by the way, the newest framework-res.apk from git, no changes.

Related

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!!!

[Q] Modded Camera.apk hardkeys

Got the modded Camera.apk from Here. I changed my hardkey Search button to function like a Menu key (my menu hardkey won't work properly). I liked the search key as a snapshot key for the camera but now with me changing 217 "SEARCH" to MENU" it doesn't work.
I downloaded APKTool and decompiled modded .apk. Now the only problem is I can't find where to change the key to take a snapshot with "MENU" pressed. I have been looking through the .smali files and not having any luck. Menu key as far as I have seen has no function in the camera app anyways so this shouldn't be a problem.
Last question I would have (which I could probably search) would be how to take the decompiled .apk and compile it back to .apk.
Is the code for the menu button 217 or is that independent of the button?
Sent from my SCH-I510 using xda premium
Within /system/usr/keylayout/qwerty.kl "key 217 SEARCH" I changed to "key 217 MENU" also I changed /system/usr/keylayout/s3c-keypad.kl "key 217 SEARCH" to "key 217 MENU".
That is how I got Search button to open Menu.
I'll take a look for you. It probably won't take too long.
Yeah it should just be changing the key event code from the search key to the menu key in a few places.
dwitherell said:
Yeah it should just be changing the key event code from the search key to the menu key in a few places.
Click to expand...
Click to collapse
The problem for me is I can't find those few places. lol Searching through all these .smali files I think I'm gonna need my search button back lol.
Edit: I opened all of the files in NotePad++ and did a search for "search" and found several items but I don't know what to change or leave.
I think what I need to change is in AbstractCameraActivity.smali
Enlightened_Rogue said:
The problem for me is I can't find those few places. lol Searching through all these .smali files I think I'm gonna need my search button back lol.
Click to expand...
Click to collapse
I'm sure substanceD will get it for ya, but camera.smali and camcorder.smali are 2 at least. It'll be in the onkeyup and onkeydown event methods (just looked at this, but memory is a bit sketchy...)
dwitherell said:
I'm sure substanceD will get it for ya
Click to expand...
Click to collapse
As you see I don't mind doing the leg work, I'm not one of these beggers out there that just want someone to build a app just for me. Thanks for giving me some pointers. I'm just trying to learn as I go. New to modding phones (trying to get better).
Enlightened_Rogue said:
As you see I don't mind doing the leg work, I'm not one of these beggers out there that just want someone to build a app just for me. Thanks for giving me some pointers. I'm just trying to learn as I go. New to modding phones (trying to get better).
Click to expand...
Click to collapse
All right, let's see if I can be helpful without doing the work for you. The Android key codes are published here: http://developer.android.com/reference/android/view/KeyEvent.html. The smali files have the hex values for these key events without the extraneous zeros. For example, you'll notice that KEYCODE_POWER is sprinkled throughout the code as 0x1a. Try to find a block of code that refers to the common keys (power, search, menu, etc.) and see how it delegates them.
OK I replaced 0x54(Search) with 0x52(Menu) [14 instances] and then Compiled with APKTool. Moved Camera.apk to /system/app/ and now phone doesn't recognize Camera.apk. I restarted, tryed setting permissions to rw-r--r-- then restarting as well and still not being recognized.
Edit: Noticed when I moved your modded the permissions where rwxrwxrw- and it still showed up without restarting.
Enlightened_Rogue said:
OK I replaced 0x54(Search) with 0x52(Menu) [14 instances] and then Compiled with APKTool. Moved Camera.apk to /system/app/ and now phone doesn't recognize Camera.apk. I restarted, tryed setting permissions to rw-r--r-- then restarting as well and still not being recognized.
Edit: Noticed when I moved your modded the permissions where rwxrwxrw- and it still showed up without restarting.
Click to expand...
Click to collapse
Did you sign it (don't)? Also, there are some sound files in /res/raw that need to stay UNcompressed for things to work properly.
All I did to compile was from Here.
Code:
apktool b <directory of decoded apk>
Never compiled any apk before. How do you not sign it and not compress some of the resource files?
Edit: Just seen this at the bottem, but I'm using APKTool 1.4.3
idroid84 said:
Issues;
I noticed that while the new version 1.2 works great on the framework-res.apk file, it seems to have issues with other System/app files like Settings.apk,Phone.apk, etc. For these files use version 1.1.1.
Click to expand...
Click to collapse
Enlightened_Rogue said:
All I did to compile was from Here.
Code:
apktool b <directory of decoded apk>
Never compiled any apk before. How do you not sign it and not compress some of the resource files?
Edit: Just seen this at the bottem, but I'm using APKTool 1.4.3
Click to expand...
Click to collapse
Well the first part shouldn't be an issue I don't think. For the second - an apk is similar to a zip file. I would use something like jzip or winrar to extract out those sound files, delete them from the apk, then drop them back in using store or storage (i.e. no) compression. Though I am doubtful not doing this would cause the phone to not recognize the apk to be honest.
I opened the Original Modded .apk with 7zip moved the res files over just playing around waiting for a response and still no luck. Also I noticed while doing that the Modded on had a META-INF folder which I moved over to my Mod and after all that moved to phone /system/app and restarted phone still no Camera in App Drawer.
Original Mod I decompile: Camera 5-14-12
My Decomipled and editied:Camera - Menu Button
I was messing around with my phone and decided to install PBJ Kernel 0524. After installing that now Root Manager won't allow Mount R/W so now I can't change system files. I guess I'm stuck with what I got for now.
Edit: Complete noob moment... Went into CWM -> Mounted System -> Installed SU again. Now works. Back to working on Camera
Enlightened_Rogue said:
I was messing around with my phone and decided to install PBJ Kernel 0524. After installing that now Root Manager won't allow Mount R/W so now I can't change system files. I guess I'm stuck with what I got for now.
Edit: Complete noob moment... Went into CWM -> Mounted System -> Installed SU again. Now works. Back to working on Camera
Click to expand...
Click to collapse
Yeah the lost root is just a permissions thing - a number of ways to fix it, and installing su is definitely one of them. Glad you got that figured out.
I looked into this more - you changed too many 0x54s... not all of those were relevant to what you wanted (only 6 were). On top of that, only two of them were changing 0x54 to 0x52 (CamcorderRecordingMenu.smali) - the other 4 (2 in Camcorder.smali and 2 in Camera.smali) were simply changing the :sswitch_ value associated w/ 0x52 to that associated w/ 0x54.
Anyhoo - end result should now be power, menu, and search take pics/start video. Here's the apk - just rename to Camera.apk and push. If it doesnt show up right away and a reboot doesnt fix it, you could try to push in recovery, or dump it in a cwm-flashable zip and flash it. Hope it works for ya!
Thank you. I figured I probably changed too many. I just opened notepad++ and find/replaced in files. I was looking through but was having a difficult time tracing what was needed and was not. How did you compile just like I posted earlier? And how did you get META-INF and not compressing resources?
Enlightened_Rogue said:
Thank you. I figured I probably changed too many. I just opened notepad++ and find/replaced in files. I was looking through but was having a difficult time tracing what was needed and was not. How did you compile just like I posted earlier? And how did you get META-INF and not compressing resources?
Click to expand...
Click to collapse
I was lazy and used one of the gui-ized apktool approaches (apkmultitool). It took care of keeping things in order. After recompiling, I opened the apk in jzip, pulled out the oggs in /res/raw, deleted them from the apk, then put them back in and set compression to store. It should be noted that you could go about things without dealing with any of this - just pull out the classes.dex from the apk, use baksmali to decompile and smali to recompile, and place new classes.dex into the apk.
I take it the apk worked for you then?
Yes it worked perfectly! Thank you. Instead of just getting what I want then not saying anything I was decompiling yours and seeing what needed to be changed. Hopefully soon I will be able to to much much more. Just a little time devotion patients and people like you to help. Thank you so much!

[Q] Decompile/Recompile APKs using APKTool

I'm trying to get into modding apps. I first wanted to decompile/recompile an unmodded app just to make sure it would work in the end.
I downloaded apktool (2.0RC4) with the JAR and BAT wrapper (on Windows 7) and got it working properly.
I pulled the /system/framework framework-res.apk from my device
I ran the following commands without any sign of error
Code:
//install framework
apktool if framework-res.apk
//decompile to \app folder
apktool d app.apk
//recompile \app folder
apktool b app
Now I went in and took the app.apk in dist folder and ran on my phone. It errored that the APK wasn't structured correctly, or something.
So I opened up both my original APK and my new APK in WinRar and copies over resources.arsc, the META-INF folder and AndroidManifest.xml.
Side question: This is supposedly supposed to re-sign the apk. I understand how this MIGHT work here since it's unmodified, but generally speaking it makes no sense if you could copy the signature to something else and say it's signed. I imagine the internal validation would fail? Should I be re-signing it myself? As long as it runs on the phone I don't care who people think it came from.
Anyway, after I copy the new APK to my phone and run it, it installs for a while then throws up "App Not Installed" with the DONE button.
I tried using APKSigner to put a bogus signature on there to see if that helped, and it did. I managed to install the APK but when it boots up it becomes unresponsive almost immediately.
How can I decompile/recompile an apk and then run it without any modifications?
Thanks in advance!
Debug Mode
After checking catlog I noticed the app tried to re-orient and broke shortly after, so after rebooting my APK it ran. I just had some bad luck.
However now that I can re-compile the application, I am trying to re-compile it in debug mode so I can step through it and find where I want to be. I have done this tutorial:
<Was unable to post link, it is entitled HowTo: Debug Android APKs with Eclipse and DDMS on blog.dornes.nu>
The steps are:
//this decompiles in debug mode
apktool d -d app.apk -o source
I then manually edited the AndroidManifest.xml and added android:debuggable='true' to the 'application' tag
//rebuild in debug
apktool b -d source app.debug.apk
Then I signed the APK using ZipSigner
Installed APK successfully
Went to developer options and used select debug app
(The Wait for Debug to Start option does keep the app from running, but when I turn it off the app boots and crashes)
So now that it is recompiled in debug, it crashes, and I've tried it many times.
I will see if I can complete the rest of the tutorial next time I'm in front of a PC, maybe with it connected to the debugger I can step through. Any reason why an app decompiled and recompiled into debug would crash?
Thanks!

Has anyone figured out Hotspot / tethering for sprint a9?

I've ran through default.xml and made some changes allowing me to access hotspot and turn it on but I cannot get any data to transfer.. anyone figure this out yet?
It should be the same as on previous devices - the APNs will need to be updated to add the dun profile and cust_cdmaconn.dat will probably need to be removed (in addition to the default.xml changes to which you refer).
Captain_Throwback said:
It should be the same as on previous devices - the APNs will need to be updated to add the dun profile and cust_cdmaconn.dat will probably need to be removed (in addition to the default.xml changes to which you refer).
Click to expand...
Click to collapse
Thanks capt'n! Where can I find information on how to update APN to add dun profile? I have the paid version of root explorer and nothing came up when I searched for cust_cdmaconn.dat
edit:
found cust_cdmaconn.dat manually in system>customize but still need to update apn to add dun profile, not familiar with that, any help would be appreciated, thanks!
Captain_Throwback said:
It should be the same as on previous devices - the APNs will need to be updated to add the dun profile and cust_cdmaconn.dat will probably need to be removed (in addition to the default.xml changes to which you refer).
Click to expand...
Click to collapse
When I goto network settings on my a9 Access point names is grey'd out :/ and i cannot access it. Im rooted lastest 1.57 stock rom s-off if that matters..
Ive searched far and wide, adding to the build.prop does not work anymore:
ril.sales_code=LOL
ro.csc.sales_code=LOL
Update:
got MSL from sprint, went into ##data# and scoped the settings. Theyre different with new update I guess. There's no APN settings or anything of the sort showing default,mms. EHRPD only shows enable or disable and LTE only shows the same, enable or disable.
Can anyone shine some light on this?
wholigan423 said:
When I goto network settings on my a9 Access point names is grey'd out :/ and i cannot access it. Im rooted lastest 1.57 stock rom s-off if that matters..
Ive searched far and wide, adding to the build.prop does not work anymore:
ril.sales_code=LOL
ro.csc.sales_code=LOL
Update:
got MSL from sprint, went into ##data# and scoped the settings. Theyre different with new update I guess. There's no APN settings or anything of the sort showing default,mms. EHRPD only shows enable or disable and LTE only shows the same, enable or disable.
Can anyone shine some light on this?
Click to expand...
Click to collapse
When I referred to editing the APN, I meant doing it in framework-res.apk, by decompiling it.
Obviously if you do that you'll need to have a stock system image backup made and dm-verity disabled otherwise your system won't boot.
Captain_Throwback said:
When I referred to editing the APN, I meant doing it in framework-res.apk, by decompiling it.
Obviously if you do that you'll need to have a stock system image backup made and dm-verity disabled otherwise your system won't boot.
Click to expand...
Click to collapse
... perhaps this is over my head but as im sure im not alone, if this could be explained in greater detail im sure more people would greatly appreciate and even maybe script into a easy program, other than myself
wholigan423 said:
... perhaps this is over my head but as im sure im not alone, if this could be explained in greater detail im sure more people would greatly appreciate and even maybe script into a easy program, other than myself
Click to expand...
Click to collapse
Not sure what else you want me to explain. Decompile the framework and add the dun profile to the standard CDMA (LTE and eHRPD) APNs. If there's a dun only APN, remove it. If you remove the read-only flag, you should be able to view the APNs in Settings.
As far as the dm-verity flag, that's explained a bit more in the TWRP thread, and I provided a boot image patches to take care of that already.
All of the tools you need can be found using search. Welcome to XDA-Developers .
Captain_Throwback said:
Not sure what else you want me to explain. Decompile the framework and add the dun profile to the standard CDMA (LTE and eHRPD) APNs. If there's a dun only APN, remove it. If you remove the read-only flag, you should be able to view the APNs in Settings.
As far as the dm-verity flag, that's explained a bit more in the TWRP thread, and I provided a boot image patches to take care of that already.
All of the tools you need can be found using search. Welcome to XDA-Developers .
Click to expand...
Click to collapse
Let me know if im on the right track..
So I've flashed the Dm verify via TWRP and Im viewing the androidmanifest.xml in the framework-res.apk-----about 2/3s the way down (viewing on phone root explorer) youll find
<permission>
name="android.permission.WRITE_APN_SETTINGS"
protectionlevel="18">
</permission>
It appears most of the items are regulated between 2 or 18. So would I be correct to assume that changing this 18 to a 2 would allow me access to the native APN settings in phone?
wholigan423 said:
Let me know if im on the right track..
So I've flashed the Dm verify via TWRP and Im viewing the androidmanifest.xml in the framework-res.apk-----about 2/3s the way down (viewing on phone root explorer) youll find
name="android.permission.WRITE_APN_SETTINGS"
protectionlevel="18">
It appears most of the items are regulated between 2 or 18. So would I be correct to assume that changing this 18 to a 2 would allow me access to the native APN settings in phone?
Click to expand...
Click to collapse
Nothing you need to edit is in the manifest. You need to edit the actual APNs, which are found in res/xml.
EDIT: Actually I don't know if changing that value will allow you to change the APN Settings. I've never figured out how to change the manifest successfully.
Captain_Throwback said:
Nothing you need to edit is in the manifest. You need to edit the actual APNs, which are found in res/xml.
EDIT: Actually I don't know if changing that value will allow you to change the APN Settings. I've never figured out how to change the manifest successfully.
Click to expand...
Click to collapse
OK so now im viewing the cdmaapn.xml and added dun to all the profiles, is that all? can I add it into the framework-res.apk directly overwriting on system?
also edited apns.xml and added dun to profiles
now how do i get them into the framework-res.apk? Can I use root explorer and copy/paste them directly in?
wholigan423 said:
OK so now im viewing the cdmaapn.xml and added dun to all the profiles, is that all? can I add it into the framework-res.apk directly overwriting on system?
Click to expand...
Click to collapse
Not sure I understand your last question. You should be able to recompile the apk, and then just drop the already compiled, modified apns into the original stock framework. That'll give you the updated APNs.
Then you'll have to delete the current telephony database in /data/data/com.android.providers.telephony/databases and possibly the shared_prefs folder if there are APNs in it.
im having an exceptionally difficult time re-compiling, most of the write ups seem out of date :/ uhg
Ive installed android sdk and latest java 64bit
heres the scirpt errors:
C:\Users\Mike\Downloads\adb-tools-1.0.31>apktool b frameworkzzz edited framework-res.apk
I: Using Apktool 2.0.0-RC2 on frameworkzzz
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.DirectoryException: java.io.FileNotFoundException: frameworkzzz (The system cannot find the file specified)
at brut.androlib.Androlib.readMetaFile(Androlib.java:247)
at brut.androlib.Androlib.build(Androlib.java:266)
at brut.androlib.Androlib.build(Androlib.java:258)
at brut.apktool.Main.cmdBuild(Main.java:240)
at brut.apktool.Main.main(Main.java:89)
Caused by: brut.directory.DirectoryException: java.io.FileNotFoundException: frameworkzzz (The system cannot find the file specified)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:54)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:37)
at brut.androlib.res.util.ExtFile.getDirectory(ExtFile.java:55)
at brut.androlib.Androlib.readMetaFile(Androlib.java:243)
... 4 more
Caused by: java.io.FileNotFoundException: frameworkzzz (The system cannot find the file specified)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(Unknown Source)
at java.io.RandomAccessFile.<init>(Unknown Source)
at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:203)
at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:182)
at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:143)
at brut.directory.ZipExtFile.<init>(ZipExtFile.java:28)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:52)
... 7 more
wholigan423 said:
im having an exceptionally difficult time re-compiling, most of the write ups seem out of date :/ uhg
Ive installed android sdk and latest java 64bit
heres the scirpt errors:
C:\Users\Mike\Downloads\adb-tools-1.0.31>apktool b frameworkzzz edited framework-res.apk
I: Using Apktool 2.0.0-RC2 on frameworkzzz
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.DirectoryException: java.io.FileNotFoundException: frameworkzzz (The system cannot find the file specified)
at brut.androlib.Androlib.readMetaFile(Androlib.java:247)
at brut.androlib.Androlib.build(Androlib.java:266)
at brut.androlib.Androlib.build(Androlib.java:258)
at brut.apktool.Main.cmdBuild(Main.java:240)
at brut.apktool.Main.main(Main.java:89)
Caused by: brut.directory.DirectoryException: java.io.FileNotFoundException: frameworkzzz (The system cannot find the file specified)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:54)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:37)
at brut.androlib.res.util.ExtFile.getDirectory(ExtFile.java:55)
at brut.androlib.Androlib.readMetaFile(Androlib.java:243)
... 4 more
Caused by: java.io.FileNotFoundException: frameworkzzz (The system cannot find the file specified)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(Unknown Source)
at java.io.RandomAccessFile.<init>(Unknown Source)
at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:203)
at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:182)
at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:143)
at brut.directory.ZipExtFile.<init>(ZipExtFile.java:28)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:52)
... 7 more
Click to expand...
Click to collapse
Update your apktool. You should be using the latest version to both decompile and recompile the APK for best results.
Captain_Throwback said:
Update your apktool. You should be using the latest version to both decompile and recompile the APK for best results.
Click to expand...
Click to collapse
Thanks, you've been a great deal of help. Now I just need to figure out how the hell to open this damn .jar file on windows 10 fml
I take it there isn't and won't be an easier way to do this.
Okay... So decompile framework-res.apk which is located in /system/framework. Navigate to res/xml. Edit apns.xml and add dun to the APNs and delete the dun APN if it is there. At this point do I have to sign the APK (it has been a long time since I've done any tinkering with APKs)? And then I push the APK back to /system/framework and chmod 644 it. Should I reboot into recovery at this point and wipe data? Or do I just have to reboot the phone and delete the current telephony database?
Or could I just recompile the APK, and then just extract the modified apns.xml from the recompiled APK and just insert the apns.xml into the stock APK?
truthfuldemise said:
Okay... So decompile framework-res.apk which is located in /system/framework. Navigate to res/xml. Edit apns.xml and add dun to the APNs and delete the dun APN if it is there. At this point do I have to sign the APK (it has been a long time since I've done any tinkering with APKs)? And then I push the APK back to /system/framework and chmod 644 it. Should I reboot into recovery at this point and wipe data? Or do I just have to reboot the phone and delete the current telephony database?
Or could I just recompile the APK, and then just extract the modified apns.xml from the recompiled APK and just insert the apns.xml into the stock APK?
Click to expand...
Click to collapse
good luck man i still havent got it 1 week in to tinkering, update us if you get plz thanks
I didn't have any trouble decompiling or recompiling the framework-res with the latest apktool, so I'm not sure why you were having issues.
I'm attaching a zip with the updated framework-res.apk in it, from the latest Sprint RUU that was available on HTC's website (1.57.651.1). While it is technically a flashable zip, I couldn't test it, so if it doesn't work, you might just be better off replacing the file manually and deleting the other files while in TWRP.
I have two asserts in the zip - one will confirm you're flashing the zip to a Sprint device, and the other will read your baseband to ensure you're on the latest firmware/software before allowing you to flash. The latter assert I'm not positive about, so if you're certain you're on the latest and the zip won't flash, I'll need a recovery log.
Additionally, I don't even know for sure whether these changes will allow tether to work on this device. So absolutely make sure you make a backup before flashing this!
Captain_Throwback said:
I didn't have any trouble decompiling or recompiling the framework-res with the latest apktool, so I'm not sure why you were having issues.
I'm attaching a zip with the updated framework-res.apk in it, from the latest Sprint RUU that was available on HTC's website (1.57.651.1). While it is technically a flashable zip, I couldn't test it, so if it doesn't work, you might just be better off replacing the file manually and deleting the other files while in TWRP.
I have two asserts in the zip - one will confirm you're flashing the zip to a Sprint device, and the other will read your baseband to ensure you're on the latest firmware/software before allowing you to flash. The latter assert I'm not positive about, so if you're certain you're on the latest and the zip won't flash, I'll need a recovery log.
Additionally, I don't even know for sure whether these changes will allow tether to work on this device. So absolutely make sure you make a backup before flashing this!
Click to expand...
Click to collapse
sweet, thanks, im testing now. and I already have the latest 1.57.651.1 RUU direct from htc website, but i ran it in twrp and attempted to flash the zip and "error: 7" came up something like your system is old and out of date, but I most definetly have the latest. So now I am extraction in root explorer and gonna over write framework-res.apk with new one...here it goes...lol. DONT do it while your phone is on. NEEDS to be done on computer. instant restart, hopefully not bricked. will update after im done panicking. (i have backed up system just incase but still...)
wholigan423 said:
sweet, thanks, im testing now. and I already have the latest 1.57.651.1 RUU direct from htc website, but i ran it in twrp and attempted to flash the zip and "error: 7" came up something like your system is old and out of date, but I most definetly have the latest. So now I am extraction in root explorer and gonna over write framework-res.apk with new one...here it goes...lol. DONT do it while your phone is on. NEEDS to be done on computer. instant restart, hopefully not bricked. will update after im done panicking. (i have backed up system just incase but still...)
Click to expand...
Click to collapse
I asked for a recovery log if the flash failed....
And flashing the zip assumes you've already removed encryption and patched your boot.img. I thought those were givens.
EDIT: I can incorporate the boot.img patches into the zip, but won't be able to delete the telephony database, since TWRP can't by default decrypt /data. So then you wouldn't be using the updated APNs, which would make the changes useless.
EDIT 2: And you can replace the framework-res directly on the phone - you just have to do it while in TWRP. That's how I make most edits to my devices.

[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