yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] olearyp:
Interesting. So it's all there, just hidden.

It would be much easier to hack on system apps if there were a version of android.jar that had all of those resources and APIs marked public. Then there should be no need to download and build the entire AOSP just to modify one from source. Might be a nice side benefit of apktool, if those changes aren't too difficult.
[G1 Android Development] Brut.all:
Apktool 0.9.2 already embeds android.jar with some private->public hacks (for DeskClock), no problem for making all resources public, but... do we need this? Do system apps really use private resources or is it just your guess? I doubt it, Android is not an iPhone and system apps are just... apps... no superpowers, sorry. That is Google, who makes some dirty hacking here, not AOSP.
[G1 Android Development] olearyp:
Actually, I'm working completely off the public APIs, so that's not a problem.

But I was looking at creating a modified PackageInstaller. PackageInstaller is a system app that does, in fact, have superpowers. :) A quick look at the unrecognized (by the SDK) imports (collected from all files)...

import android.content.pm.IPackageInstallObserver;
import android.os.FileUtils;
import android.content.pm.PackageParser;
import android.widget.AppSecurityPermissions;
import android.content.pm.IPackageDeleteObserver;

Is wanting to modify in this way a common use case? Admittedly, no. And I suppose I could just get off my butt and download the platform. It was just a thought because I wasn't expecting those things to be in there--I thought they would be completely absent.
[G1 Android Development] Brut.all:
Bad Android, bad... ;-)

No problem though, in current version of apktool I have framework libs embedded too, because they are needed for Java code compilation (I mean these new features from last video).
[G1 Android Development] olearyp:
LOL. It's really not unreasonable; in general, no one is going to touch those system apps, so treating them as part of the core userspace isn't crazy.

And maybe this reflects a fundamental misunderstanding on my part. :D I'll stop bothering you and let you get some work done now.
[G1 Android Development] rac2030:
Just some coding fun...

From AOSP Source in Watchdog.java:

/**
* Determine whether it is a good time to kill, crash, or otherwise
* plunder the current situation for the overall long-term benefit of
* the world.
*
* @param curTime The current system time.
* @return Returns null if this is a good time, else a String with the
* text of why it is not a good time.
*/
String shouldWeBeBrutalLocked(long curTime) {
if (mBattery == null || !mBattery.isPowered()) {
return "battery";

don't know what ocked could mean but the name of this Method "should we be brutall" ;-)

But the comment clearly has the flavor of world domination

See http://strazzere.com/blog/?p=325
[G1 Android Development] canadiancow:
Wtf is a brutal lock anyway.
[G1 Android Development] mic_888:
Thanks for this, can't wait to try it out when I get a chance :)
[G1 Android Development] tommytomatoe:
Hatman,

Have you ran "apktool if" on the com.htc.resources.apk from the particular Rom the HTC clock apk is from? It doesn't have to be same Rom, but at least same base version. Like Sprint EVO 3.70 or something, just an example.
[G1 Android Development] Hatman41:
Yes I have done that. I just tried it again though and this time it worked...very weird.
[G1 Android Development] tommytomatoe:
Good job then! Hehe. Weird.
[G1 Android Development] redsock:
Uh im trying to make my status bar transparent but I got this error when recompling and I have no idea what it is o_o Any suggestions? :P
[G1 Android Development] Brut.all:
You don't have aapt in your PATH. See installation instructions.
[G1 Android Development] Hatman41:
You could also use a different compile line. I use apktool b -f -d ./dir where file is that you want to compile example apktool b -f -d ./outclockblue now the path is the issue but thought I would show you a cleaner compile command. I also use apktool d HtcClockWidget.apk ./outclockblue as a decompile command ./outclockblue being the dir that I want it decompiled in.
[G1 Android Development] tommytomatoe:
Even though it is good to get your apktool up and running again, the status bar is controlled by a png of the same name. You don't need to decode and recode anything for this task. :-)
[G1 Android Development] pendo:
Actually in gingerbread, you have to make some smali edits in StatusBarService for transparency. Then there is the png and hex code in layouts.
[G1 Android Development] tommytomatoe:
Aww. I didn't realise we are dealing with gb. :-) I assumed froyo.

In that case, yep. What Pendo said. :-)
[G1 Android Development] SupremeBeaver:
Hi guys,

Im using apktool to try decompile HTC_IME.apk which is their keyboard. I installed the relevant framework files and run the decompile command but i get this:

Anybody know what's happening here?
[G1 Android Development] m3dteam:
can anyone please help me,

I am trying to debug smali code line by line without any modification, but following the wiki (apktool d -d x.apk then apktool b -d x) did not work. DDMS did not pick up the app and when starting it it did not give the massage about debugging. I also tried to run it through eclips with the debug options but it cannot build it properly.

Also, how do I get the source file, just like in the video? (smali is fine but separating functions is cool).
[G1 Android Development] Brut.all:
Use this one: http://www.multiupload.com/BPJW0WGTBG

Did you add debuggable="true" to your manifest?

It's not implemented.
[G1 Android Development] SupremeBeaver:
Dude you're awesome! It worked.
[G1 Android Development] jbbandos:
Hi guys,

I am trying to edit both a MIUI application and the framework-res.apk. The strange thing is that all seems to work, but then fails when placed in the N1. For instance, if I extract Launcher2 or framework-res.apk with "apktool d Launcher2.apk ./expanded/" and just repackage it won't give any errors, but for the framework it will make the N1 stuck in a loop, if I just try with an app it will malfunction, giving FCs, etc.

What am I doing wrong here? There are no errors from apktool, and I am using the right framework in ~/apktool/framework/1.apk

Thanks.
[G1 Android Development] darkm20:
Any idea ??

I tried also with the last 1.4.2 posted in this thread.

Thanks

I: Baksmaling...
testI: Loading resource table...
I: Loaded.
I: Loading resource table from file: C:\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
W: Could not decode attr value, using undecoded value instead: ns=android, name=
fragment, value=0x0000000b
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at brut.androlib.res.util.ExtMXSerializer.writeAttributeValue(ExtMXSeria
lizer.java:38)
at org.xmlpull.mxp1_serializer.MXSerializer.attribute(MXSerializer.java:
673)
at org.xmlpull.v1.wrapper.classic.XmlSerializerDelegate.attribute(XmlSer
ializerDelegate.java:106)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.writeStartT
ag(StaticXmlSerializerWrapper.java:267)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.event(Stati
cXmlSerializerWrapper.java:211)
at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDe
coder.java:46)
at brut.androlib.res.decoder.ResStreamDecoderContainer.decode(ResStreamD
ecoderContainer.java:34)
at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:1
00)
at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:8
6)
at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:132
)
at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:93)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:98)
at brut.apktool.Main.cmdDecode(Main.java:120)
at brut.apktool.Main.main(Main.java:57)
[G1 Android Development] KBanause:
It seems like you have forgotten to install the framework-file

java -jar apktool.jar if PATH/TO/framework-res.apk

(repeat for any other framework-file your ROM is using)
[G1 Android Development] darkm20:
Hi,

I did it of course...but doesn't work :(

I'm using the exact framework-res.apk my device is using.
[G1 Android Development] KBanause:
Do you have an AOSP ROM?

Greetings,

KBanause
[G1 Android Development] tommytomatoe:
@darkm

What apk are you trying modify? Let's start there. If it is an HTC apk, you also need to install com.HTC.resources.apk.
[G1 Android Development] jbbandos:
Sorry for bringing this up again, but can someone give me some indication on what I should be looking for to solve this? I am at a loss on how to find why the resulting framework-res.apk isn't working, or even a more basic change of Launcher2.apk's default-workspace.xml (without touching the framework or anything else) seems to corrupt it to an extent that the lock screen won't be shown - and the default-framework.xml I am trying to use is the one that comes with the Chinese-only version, so I know it isn't buggy.

I am even thinking of expanding with apktool, editing, repacking, then extracting the packed files with a zip utility and addind the packed files to the original .apk.
[G1 Android Development] jbbandos:
Ok, for Launcher2.apk I was being a tool. I forgot to sign it. Now it works, no problems. But MIUI's framework-res.apk is a different problem. Maybe it is because I want to edit res/values/bools.xml, but I don't really understand what am I doing wrong here. I do exactly the same steps as for the working Launcher2.apk, I unpack it with "apktool d -f framework-res.apk ./decoded/", edit decoded/res/values/bools.xml, and repack it with "apktool b ./decoded/ unsigned-framework-res.apk". I then sign it, and it still gives bootloops when flashed or adb pushed. :(

Any idea on what am I doing wrong here?

Thanks.
[G1 Android Development] Brut.all:
Could you upload this apk (and framework, if needed) somewhere (peferably multiupload.com).

Don't resign system files. Unzip it, copy META-INF and AndroidManifest.xml from original apk, zip it back and push to device. Sorry for your inconvenience ;-)
[G1 Android Development] jbbandos:
Doh... Thanks Brut.all, you rule (as always), I'll try it asap, hopefully I'll be able to edit framework-res properly now.
[G1 Android Development] Treken:
A couple of questions. Is an apk theme for theme chooser a system apk(I'm thinking it is since it changes system settings)? Also, If it is a system apk, how do I push it to my phone/if not, how do I resign it? Thanks for any help.
[G1 Android Development] xavierjohn22:
Dont sign framework

Use my windows xdaautotool it has bruts apktool. See my sig. It

will crReate you apks you can use apart fom bruts build folder.

Sent from XJ's Desire... LOL
[G1 Android Development] jbbandos:
Hi David,

Thanks for your suggestion, but as I wrote you before I don't have windows on my machines, so I'd have to install a virtual machine or get your tool to work with wine. Anyway, I got it to work by adding the META-INF folder and the AndroidManifest.xml from the original framework-res.apk. It is less work than booting a windows virtual machine or installing a windows partition on my netbook.
[G1 Android Development] Joe31:
apktool

Hi everybody!

I decompressed the settings.apk file (Motorola Defy) with the apktool! It was successful! But there was problem with the recompression! Apktool stops at the following message: Building resources.....it works here for a long time end is it goes on, a lot off problems occur........

Have you got any idea???

Thanks!
[G1 Android Development] anderl78:
Hi Brut,

Thank you for this wonderful tool!
[G1 Android Development] klquicksall:
True brut is the theme god father lol

Sent from my DHD / Inspire 4G
[G1 Android Development] tommytomatoe:
No doubt. Without him 92% of this wouldn't he possible.
[G1 Android Development] dully79:
Been very busy lately and only just seen the update, thanks Brut.all.:)

I created a little right click reg-edit for windows based on your tool here, hope you dont mind.

If you have any objections just let me know!!??
[G1 Android Development] Locster126:
OK I'm decompiling SystemUI.apk (using framework-res.apk for same ROM), once decompiled without

any changes

(just testing) I compile it again (opt. 11 - system - yes) and sign it and the file is 209kb instead of the original 257kb.

Problem is when I adb push it it won't install, when booting no statusbar is visible...for the life of mine I can't figure out whats wrong.

Is there a special way to compile/decompile SystemUI.apk?
[G1 Android Development] klquicksall:
Ok are you using a sense rom? In any case you need the meta-inf and Android manifest from the original apk.
[G1 Android Development] mb02:
Hey guys, I'm having trouble working with Rosie.apk from an evo3d port. I have no problem decompiling or recompiling any other apks from this rom or any other, including other Rosies. For some reason, this one apk is the only one giving me problems. Here's the errors when compiling:

c:\>apktool b Rosie Rosie1.apk
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
libpng error: Read Error
ERROR: Failure processing PNG image c:\\Rosie\res\drawable\all_apps_divider.9.pn
g
libpng error: Read Error
ERROR: Failure processing PNG image c:\\Rosie\res\drawable-hdpi\all_apps_divider
.9.png
c:\\Rosie\res\values\public.xml:87: error: Public symbol drawable/activity_title
_bar declared here is not defined.
c:\\Rosie\res\values\public.xml:88: error: Public symbol drawable/alarm declared
here is not defined.
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
ption: could not exec command: [aapt, p, -F, C:\Users\MIKEYB~1\AppData\Local\Tem
p\APKTOOL2559603846819444637.tmp, -I, C:\Users\Mikey B\apktool\framework\1.apk,
-I, C:\Users\Mikey B\apktool\framework\2.apk, -S, c:\\Rosie\res, -M, c:\\Rosie\A
ndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:193)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:301)
at brut.androlib.Androlib.buildResources(Androlib.java:248)
at brut.androlib.Androlib.build(Androlib.java:171)
at brut.androlib.Androlib.build(Androlib.java:154)
at brut.apktool.Main.cmdBuild(Main.java:174)
at brut.apktool.Main.main(Main.java:59)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, C:\U
sers\MIKEYB~1\AppData\Local\Temp\APKTOOL2559603846819444637.tmp, -I, C:\Users\Mi
key B\apktool\framework\1.apk, -I, C:\Users\Mikey B\apktool\framework\2.apk, -S,
c:\\Rosie\res, -M, c:\\Rosie\AndroidManifest.xml]
at brut.util.OS.exec(OS.java:83)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:191)
... 6 more

There were MANY more instances of "Public symbol drawable/* not defined" for res/values/public.xml, cut them out to size down the error log. Basically every drawable defined in the xml threw this error, but the thing is all of the drawables exist and are where they are supposed to be. Also, this is from a straight decompile and compile, no edits made. I have my sdk in PATH as well as apktool 1.4.1 in my windows dir so aapt shouldn't be a problem. Anybody have any ideas??
[G1 Android Development] Locster126:
nope, no sense ROM, just touchwiz 4 on the galaxy s2...hmm any other ideas?
[G1 Android Development] tommytomatoe:
You will also want the tw framework apk in addition to framework res.apk.

Sense has com.htc.resources.apk. I know touchwhiz has one similar.

And yes for all system apks you need to transfer ORIGINAL meta inf and androidmanifest from ORIGINAL apk. It's not just a sense thing. :-)
[G1 Android Development] coiledwire:
+1. Also, I've noticed a normal reboot is sometimes required to have the status bar appear. I have no idea why this happens.

If you're able to bootup ok after applying the your changes, and everything appears to be normal except for a status bar, try a normal reboot.

Sent on the go, from my evo.
[G1 Android Development] kia1349:
after build apk , does it need to signe apk or no?
[G1 Android Development] tommytomatoe:
Data app (third party, market app) = signed. Test sign usually works for most apks.

System app (apps that go in system/app) = not signed. Look at a couple posts above. You need to transfer original meta inf and AndroidManifest.xml from ORIGINAL apk to new one, the one in "dist" folder.
[G1 Android Development] Enes_81:
Damn, I can't get it to work ..

Can somebody please ad com.android.email.permission.READ_ATTACHMENT to Polaris
[G1 Android Development] alienmind:
Hi, first of all beg your pardon if my noobish question is already answered, couldn't find info.

What I'm trying to do is to mod MiuiCamera to use with CM7 without the asian strings

Of course, the first approach was to use latest source from miui and remove them.

But looks like latest version is heavily dependent on miui's framework, there was a point where CM7 and miui frameworks where almost identical (that's why I suppose there are compatible miuicameras floating around), but not anymore...

So, second approach, use the older version (the already included, compatible) and mod using apkbuilder.

It looks pretty easy, decompress, overwrite chinese strings with eng ones and rebuild... but resulting in a broken apk that FC's at start (looking for resources that are there...)

So I simplified the task. Just trying to decrypt, and rebuild, without changes. Same result.

As you see, this is my first experience with apkbuilder and I'm not getting great results... help appreciated.

PS: I tried to framework-res from both CM7 or miui, same result
[G1 Android Development] Maedhros:
Hi

Im trying to compile an APK.

It is a SystemUI from HTC Sense rom.

I can decompile. But even if I dont change anything I cant recomplie.

This is my error:

C:\android-sdk-windows\tools>apktool b -f SystemUIStock
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.PathN
otExist: apktool.yml
at brut.androlib.Androlib.readMetaFile(Androlib.java:142)
at brut.androlib.Androlib.build(Androlib.java:159)
at brut.androlib.Androlib.build(Androlib.java:154)
at brut.apktool.Main.cmdBuild(Main.java:174)
at brut.apktool.Main.main(Main.java:59)
Caused by: brut.directory.PathNotExist: apktool.yml
at brut.directory.AbstractDirectory.getFileInput(AbstractDirectory.java:
103)
at brut.androlib.Androlib.readMetaFile(Androlib.java:138)
... 4 more

I am trying to compile the attached files!

thanks!

(I ziped it, but its a folder in the zip file)
[G1 Android Development] KBanause:
Normally, apktool creates a file apktool.yml in the same directory as the AndroidManifest.xml when decompiling a file. You must have deleted it by accident.
[G1 Android Development] pendo:
I assume you're talking about the theme chooser in Cyanogen. The two included themes are system apks, but that's only because their distributed with the rom. You can actually build your own themes using available templates, which then are installed as user apps in /data. That said, I have edited the two included versions in /system. They are signed with the aosp test cert so you could resign with it, or copy the META-INF and AndroidManifest from the original.

Seems this type of thing is being brought up a lot recently....I wanted to point out that if you're working with an entire rom, you can actually resign system apks. The way to go about this is to identify which apk's in /system/app share the same certificate as framework-res. Then once you've identified those, resign them and framework-res.

Here's a script that you can run in a directory that will group apks into 1 of 5 folders...one for each of the aosp certs and one for other if they're signed by something else. I am not the original creator of this script, Paul O'brien is, although I've edited it ever so slightly ;)

for filename in *.apk
do
unzip -d $filename.extract $filename META-INF/CERT.RSA
if [ -f $filename.extract/META-INF/CERT.RSA ]
then
mkdir `keytool -printcert -v -file $filename.extract/META-INF/CERT.RSA|grep SerialNumber| cut -c 19-23`
mv $filename `keytool -printcert -v -file $filename.extract/META-INF/CERT.RSA|grep SerialNumber| cut -c 19-23`/$filename
mv `echo $filename | sed 's/\(.*\.\)apk/\1odex/'` `keytool -printcert -v -file $filename.extract/META-INF/CERT.RSA|grep SerialNumber| cut -c 19-23`/`echo $filename | sed 's/\(.*\.\)apk/\1odex/'`
rm -rf $filename.extract
else
mkdir none
mv $filename none
mv `echo $filename | sed 's/\(.*\.\)apk/\1odex/'` none
rm -rf $filename.extract
fi
done;

mkdir other
mv * other
mv other/b399 platform
mv other/f2a7 shared
mv other/f2b9 media
mv other/936e test

Then in the folder that you find framework-res.apk in, resign all those with the platform certificate This is my script for that (keep in mind you may have things in a different directory)

for i in *.apk
do
java -jar /usr/local/bin/signapk.jar /usr/local/bin/platform.x509.pem /usr/local/bin/platform.pk8 $i $i.signed
rm $i
mv $i.signed $i
done

**This will require a wipe, or you will have issues with /data/system/packages.xml**

No, not a special way per se, but you should probably use a tag from the framework files of the rom in question. For instance, if I'm working on Acme Rom, I would install and tag framework like this

apktool if framework-res.apk Acme]or whatever framework the rom has. Then I'd decompile SystemUI as[apktool d -t Acme SystemUI.apk]
Next, you don't "install" SystemUI or really any other system apk. You do use adb push as you mention, and while you can do this with core running with some apk's, SystemUI is not one of them. You need to have core stopped when you do this, either by running "adb shell stop" then push, then "adb shell start" or by pushing while in recovery.
[G1 Android Development] Maedhros:
Thanks for the response!

I haven't modified any of those files tho.

Also, I get the same Error when I Decompile an APK and try to recompile without editing anything! :(
[G1 Android Development] pendo:
If you didn't remove the apktool.yml file from the decompiled output, then you must've changed directories or something..... your error clearly says it doesn't see apktool.yml in the path that you're calling.
[G1 Android Development] tommytomatoe:
Were there errors in your decompile process?
[G1 Android Development] Maedhros:
hmm I haven't tho.

This is what it says when I decompile :

C:\Users\Arjun\Desktop\APKS>apktool d SystemUI.apk
I: Baksmaling...
testI: Loading resource table...
I: Loaded.
I: Loading resource table from file: C:\Users\Arjun\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x02050029
W: Could not decode attr value, using undecoded value instead: ns=android, name=
textSize, value=0x0205002e
I: Decoding values*/* XMLs...
I: Done.
Can't find framework resources for package of id: 2. You must install proper fra
mework files, see project website for more info.

BTW thanks every1 for the help :)
[G1 Android Development] tommytomatoe:
That is your issue. The apktool.yml doesn't get created because you did not decompile properly, thus you cannot build.

Which Rom or device is this for? If you on HTC device, you will also need to run "apktool if com.htc.resources.apk", where the com.htc.resources.apk is from the same Rom as SystemUI.apk. Similarly, if you on Samsung, you will need the touch whiz resource apk. I don't know the name of that one.
[G1 Android Development] Maedhros:
Thank you!

Now I will finnaly be able to help people out with customization, and get them off Rom Dev's backs :D

Love u guyss (no homo) :p
[G1 Android Development] tommytomatoe:
Happy for you man.
[G1 Android Development] Mioze7Ae:
Perhaps this could be added to the apktool FAQ? I wasted a lot of time on this.
[G1 Android Development] vegetaleb:
apktool noob here:

I have troubles recompiling systemui.apk with apktool, I have installed framework into user/apktool as asked, decompiling the systemui is giving this:

By the way why is it pointing to ''other'' folder and not directly to ''projects''?