yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] Daneshm90:
Heres ur problem,

I/PackageManager( 1188): /system/framework/framework-res.apk changed; collecting certs

D/dalvikvm( 1188): GC_FOR_MALLOC freed 4022 objects / 332632 bytes in 59ms

E/PackageParser( 1188): Package android has no certificates at entry AndroidManifest.xml; ignoring!

Apktool removes the original signature, try this:

Take the meta-inf from the original framework-res and put it inside ur modified one. See if that works, it should as its a system app and certs dont have to match if i recall.
[G1 Android Development] raidzero:
same thing, here is an updated logcat: http://pastebin.com/6MdHgiWt
[G1 Android Development] Daneshm90:
K try taking the original AndroidManifest.xml and putting it in 2 ur modified apk.
[G1 Android Development] raidzero:
I wil have to get back to you tomorrow, I am off to bed right now.. thanks for your help!
[G1 Android Development] Brut.all:
About size differences: no magic here, you could easily compare two files and find by yourself, what is going on. Apktool doesn't compress resources.arsc file - that's all. I have an issue about that: http://code.google.com/p/android-apktool/issues/detail?id=67

About certs issues: I'm not an expert of system modifications, but I always replace framework-res.apk file through update.zip method. This is only way I know, that works.
[G1 Android Development] raidzero:
Thanks for the info. I have never applied a framework-res.apk through update.zip, I just use adb to push it in recovery. Looks like I will be turning to the old hex-editor.
[G1 Android Development] Daneshm90:
Hmmm, cool so its just a compression issue.

As for the certs for system apks, i think core only cares about the signatures being the same and the manifest.xml being the same, other than that u can change everything else as long as u include the original META-INF folder and AndroidManifest.xml. Now im speaking not from technical knowledge but experience, so dont take my words literally. I still don't get why update.zip method is working for u guys but pushing it and restarting doesnt. Like when u sign an update.zip ur not signing the apks within it and all update.zip's do is push the file to ur phone, so the only plausible explanation i can think of is that pushing framework-res while core is running is a lot riskier than pushing when core is not.

As a test if u want to try, pull /system/app/Contacts.apk. Decompile it, modify something in androidmanifest.xml and recompile it. Include the original META-INF folder and push it to ur phone. In the log u'll see "digest for manifest.xml doesnt match or w/e". Now u can change essentially anything else in the apk (xmls,images...) and recompile and as long as u include the META-INF folder and AndroidManifest.xml, it wont complain.

Now brut heres my question, does the update.zip method work if u edit the manifest.xml of a system apk ?
[G1 Android Development] Brut.all:
Apktool really doesn't do anything unusual. It just builds apk file in the similar way as Android SDK does. I don't understand, why apktoold' apk would behave differently than hex-edited one.

Ahh and I can't push framework-res.apk file after hex-editing as well - certs problems.

Some time ago I was talking about this with JesusFreke: he said that if you replace framework-res.apk file and new file will have exactly the same modify time as original one, then system won't even look at certs. update.zip method keeps all meta data of a original file - simple pushing overwrites them.

People use this update.zip trick because it's easy to use and you don't need any tools on recovery side, so it's platform-independent.

Yeah, it works perfectly ok.

I think you may be right that Android checks only manifest digests. This would explain, why apktoold' apk would be treated differently than hex-edited one - after using apktool AndroidManifest.xml will always differ, even if you didn't modify it.

I want to fix these issues in apktool, but first I must know, what is going on exactly. If you're right, then apktool could copy original AndroidManifest.xml file if it wasn't modified. And if it was, then it will warn you, that you can't just push resulting apk, but use update.zip method.
[G1 Android Development] Daneshm90:
Damn that dude knows way too much :p Finally some technical info that make sense.

Ok so now update.zip makes sense, so essentially even mounting in recovery/pushing file would work.

So wht it comes down to is if ur modifying anything besides AndroidManifest.xml, ur free to push it to ur phone, but if ur editing that xml then u have to resort to alternatives.

I know theres one more way i remember seeing someone use.

U can "adb shell stop"

Push the file to ur phone

Then "adb shell start"

This should stay true to wht Jesusfreke said as it stops core, so modify time will remain same when u start it again.

Hmm yea so it could check whether manifest was changed, if it was warn the user that simply pushing this wont work, he must create an update.zip/push it in recovery. Also perhaps u cud introduce a new parameter "-s" where if used it signifies that u are modifying a system apk and hence apktool will preserve the META-INF folder ?
[G1 Android Development] Rotordroid:
Ok...so putting the manifest.xml AND the META INF folder from the original framework-res into the recompiled framework-res worked!! It booted. Now just need to solve the resources compression issue.

Thanks guys, you have been great and very responsive.
[G1 Android Development] dully79:
Does anyone have an idea how to resolve these errors?

"C:\Documents and Settings\Mark>apktool d C:\org.fagod.wfc_widget.apk C:\wfc

I: Baksmaling...

I: Loading resource table...

I: Decoding resources...

I: Loading resource table from file: C:\Documents and Settings\Mark\apktool\fram

ework\1.apk

S: Could not decode file "drawable/panel_background.9.png" to "drawable/panel_ba

ckground.9.png"

S: Could not decode file "drawable/widget_bg_normal.9.png" to "drawable/widget_b

g_normal.9.png"

S: Could not decode file "drawable/widget_bg_pressed.9.png" to "drawable/widget_

bg_pressed.9.png"

S: Could not decode file "drawable/widget_bg_selected.9.png" to "drawable/widget

_bg_selected.9.png"

I: Copying assets and libs..."
[G1 Android Development] Rotordroid:
I have seen that when the 9patches being decompiled were not properly formed (i.e. missing the stretch ticks). Usually happens when someone just changes the color of a 9patch and doesn't redraw the ticks and recompile. When the decompiler runs, it can't find the ticks so it can't decode them

That's my theory and I'm stickin to it....
[G1 Android Development] Daneshm90:
U've got the right idea, but that theory applies to when ur building an apk, not when decoding it ;)

So in his case, its probably decoding an apk that has dependencies on non-stock framework and he needs to (if the framework).
[G1 Android Development] Brut.all:
http://code.google.com/p/android-apktool/issues/detail?id=58

http://code.google.com/p/android-apktool/issues/detail?id=59

And actually I was warning you, that 1.3.1 may have problems with decoding some 9.png files. Revert to 1.2.1 or wait for a fix.
[G1 Android Development] he_stheone64:
I`m successfully working with your great tool, but since yesterday I keep getting this error

Exception in thread "main" brut.androlib.AndrolibException: brut.directory.Direc

toryException: file must be a directory: framework-res-decoded

at brut.androlib.res.AndrolibResources.decode(Unknown Source)

at brut.androlib.Androlib.decodeResourcesFull(Unknown Source)

at brut.androlib.ApkDecoder.decode(Unknown Source)

at brut.apktool.Main.cmdDecode(Unknown Source)

at brut.apktool.Main.main(Unknown Source)

Caused by: brut.directory.DirectoryException: file must be a directory: framewor

k-res-decoded

at brut.directory.FileDirectory.<init>(Unknown Source)

... 5 more

So far I decompiled and compliled apps and framework for various themes without issues for Milestone 2.34 and 2.36 (G.O.T. - added the 2.36 resources, no probs), but now it stopped working. Any ideas? thx in advance
[G1 Android Development] Brut.all:
What command did you ran? Do you have framework-res-decoded file in your working directory?
[G1 Android Development] he_stheone64:
The command was java -jar apktool.jar d framework-res.apk framework-res-decoded

I deleted the framework-res decoded in c://windows before that command and I have both 2.34 and 2.36 (as 2.apk) in home/apktool/framework

Strange thing, the command works since at least 2 months, but now trouble started.
[G1 Android Development] Brut.all:
Apktool doesn't handle IO errors very well, so error messages may be misleading. I think your problem is that you try to decode app to C:\windows dir, which is write protected for normal user. Decode it to other place.

You shouldn't mess up your system directories anyway :-)
[G1 Android Development] he_stheone64:
Thx - but it worked in this directory for 2 months, so it is not the write protection. So I try to dig deeper...

Edit: Finally I moved everything to c://apktool and it works again. Who knows, why it worked for so long in windows...

Big thx anyway :-)
[G1 Android Development] dully79:
Do you have a link for 1.2.1 please, i cant find it, thanx.:)
[G1 Android Development] Brut.all:
http://code.google.com/p/android-apktool/downloads/list?can=1
[G1 Android Development] dully79:
Cheers mate, ive literally just found it using the search option in the download section, it's been a looooong day.:confused:

Thanx again.;)

Edit: just ran apktool 1.2.0 and it ran like a dream!!

Problem solved.:D
[G1 Android Development] he_stheone64:
I made a custom version in black with white text of the DroidX LatinIME for one of my Themes. Unfortunately during decoding apktool changes & in &amp and &lt on the buttons, which looks kinda weird. So I dived into the strings.xml and eliminated these errors, but then I get the following error when try to repack.

c:\apktool\LatinIME-decoded\res\values\public.xml:221: error: Public entry ident

ifier 0x7f0a0051 entry index is larger than available symbols (index 81, total s

ymbols 77).

I had the same issue aftert trying to add more alternates to when long pressing a certain character and I certainly added the references in public.xml.

I know that all values of strings have to have a reference in public.xml, but do you have any idea how to solve the issue? Many thx in advance
[G1 Android Development] Daneshm90:
Heres a trick i used when porting the droidx keyboard,

Once u modified and recompiled ur apk, take from the original apk all the files that u did not modify (xmls) and place them inside ur modified apk, resign and install. BAM !!! ;)
[G1 Android Development] mytharak:
If this could only do ninepatch files it would be perfect.
[G1 Android Development] Brut.all:
It could...
[G1 Android Development] raspdeep:
hi brut.all, i just wanted to say thank you for the great tool you have contributed to the community, i would really love to use it but it seems that it doesnt work on devices other than htc?

i tried to run it on galaxy s i-9000 framework-res.apk but it wont boot.. my aim is to do the percentage battery mod. After much test and tips from the thread, i just copy the affect battery_stats.xml and replace with original but it still doesnt work. It shows blank area in the battery. i tried to decode the framework with modified battery.xml and it spilled out something like "undecoded value instead: ns=android, name=drawable, value=0x28234" blah blah.. and i went back to look at the xml and indeed replace the "@drawable".. with hex numbers except for the default ones at 0, 20, 40, 60, 80, 100 percent.. this lead me to think that although this has changed, resources such as the pngs are not added into the resources file..

So, I believed the problem is due to added resources.ascr that I did not replace. I tried replacing the resources.ascr, it wont boot.. If I decode the modified framework-res.apk with resources and battery.xml, it gave me drawable_hdpi_v4 which is different format from galaxy's framework.. hence i'm stuck

below is the framework-res.apk for anyone interested in helping..

http://xdaforums.com/showpost.php?p=7251081&postcount=100

it will be a really cool tool if it works on other phones as well..
[G1 Android Development] Brut.all:
It works for virtually every device. Some time ago I was talking with a guy, who

was using apktool against hacked e-book reader or something like that. This device had modded/non-standard framework resources, but apktool was working perfectly ok with it.

http://code.google.com/p/android-apktool/wiki/ReportingIssues

I should create a FAQ. Boot problems after modifying framework is most frequent issue, but it's not related to apktool, but signing.

I don't support mixing stuff from many apks. It may work, but does not have to.

And what did you actually do? Replaced images? Added, removed?
[G1 Android Development] raspdeep:
ok, i was not very clear with my explanation.. here are my steps:

1) add pngs into drawable-hdpi with every percentage 1-100.pngs

2) modify battery_stats.xml in drawable to indicate every 1 percent increment relates to the pngs

3) build the apk

4) from out.apk, i extracted the battery_stats.xml and pngs into the original framework-res.apk

5) create update.zip with new framework-res.apk into sdcard

6) recovery update.zip

system bootup but show blank battery..

from above, it was obvious why it wont work because added pngs are not updated in resources.acrs.. so i added resources.acrs into framework-res.apk and repack update.zip..

it wont boot
[G1 Android Development] Daneshm90:
Right and are u preserving the original meta-inf folder of the apk ? cuz apktool upon decompiling an apk gets rid of it.

K nvm, read ur post wrong....

Can u post ur log while booting ur phone ?
[G1 Android Development] raspdeep:
I think this is the problem:

D/dalvikvm( 2271): Trying to load lib /system/lib/libsrec_jni.so 0x0
D/dalvikvm( 2271): Added shared lib /system/lib/libsrec_jni.so 0x0
D/dalvikvm( 2271): Trying to load lib /system/lib/libsrec_jni.so 0x0
D/dalvikvm( 2271): Shared lib '/system/lib/libsrec_jni.so' already loaded in sam
e CL 0x0
D/dalvikvm( 2271): GC freed 435 objects / 21288 bytes in 7ms
D/asset ( 2271): Data exceeds UNCOMPRESS_DATA_MAX (3959636 vs 2097152)
D/asset ( 2271): Data exceeds UNCOMPRESS_DATA_MAX (3959636 vs 2097152)
W/ResourceType( 2271): Unable to get buffer of resource asset file
W/ResourceType( 2271): Resources don't contain package for resource number 0x010
b0001
W/dalvikvm( 2271): Exception Landroid/content/res/Resources$NotFoundException; t
hrown during Landroid/text/AutoText;.<clinit>
E/Zygote ( 2271): Error preloading android.text.AutoText.
E/Zygote ( 2271): java.lang.ExceptionInInitializerError
E/Zygote ( 2271): at java.lang.Class.classForName(Native Method)
E/Zygote ( 2271): at java.lang.Class.forName(Class.java:237)
E/Zygote ( 2271): at java.lang.Class.forName(Class.java:183)
E/Zygote ( 2271): at com.android.internal.os.ZygoteInit.preloadClasses(Zyg
oteInit.java:295)
E/Zygote ( 2271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja
E/Zygote ( 2271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja
va:583)
E/Zygote ( 2271): at dalvik.system.NativeStart.main(Native Method)
E/Zygote ( 2271): Caused by: android.content.res.Resources$NotFoundException: R
esource ID #0x10b0001
E/Zygote ( 2271): at android.content.res.Resources.getValue(Resources.java
:891)
E/Zygote ( 2271): at android.content.res.Resources.loadXmlResourceParser(R
esources.java:1865)
E/Zygote ( 2271): at android.content.res.Resources.getXml(Resources.java:7
79)
E/Zygote ( 2271): at android.text.AutoText.init(AutoText.java:160)
E/Zygote ( 2271): at android.text.AutoText.<init>(AutoText.java:76)
E/Zygote ( 2271): at android.text.AutoText.<clinit>(AutoText.java:56)
E/Zygote ( 2271): ... 6 more
D/AndroidRuntime( 2271): Shutting down VM
W/dalvikvm( 2271): threadid=3: thread exiting with uncaught exception (group=0x4
001b180)
D/dalvikvm( 2271): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 2271): DestroyJavaVM shutting VM down
D/dalvikvm( 2271): VM cleaning up
D/dalvikvm( 2271): LinearAlloc 0x0 used 1470524 of 5242880 (28%)
D/skia ( 2271): purging 6K from font cache [1 entries]
I/ServiceManager( 2181): Waiting for sevice SurfaceFlinger...
I/ServiceManager( 2181): Waiting for sevice SurfaceFlinger...
W/SurfaceComposerClient( 2181): SurfaceFlinger not published, waiting...
I/ServiceManager( 2181): Waiting for sevice SurfaceFlinger...
I/ServiceManager( 2181): Waiting for sevice SurfaceFlinger...
D/AndroidRuntime( 2271):

the built resources.acsr is a lot smaller in size compared to the original so i guess some information is lost either during decoding or building
[G1 Android Development] cmstlist:
Could APKtool be used with SIM Toolkit (Stk.apk) to create a version that does not have to be a system app or flashed as part of a ROM? I would really like to be able to install SIM Toolkit on my stock-but-rooted Froyo Nexus One. Apparently the only way to make this work so far is to flash a ROM that contains it.
[G1 Android Development] Daneshm90:
Does it have a shared uid ? (check the manifest.xml) If it doesnt, then yea u shud b able to install it as a stand-alone just fine.

EDIT : So yea it uses the shared uid : android.uid.phone

Hence any app that uses that shared uid must be signed with the same keys.

EDIT 2 : So wht happens if u try to install it on a rom ? wht does adb complain about ?
[G1 Android Development] cmstlist:
If I just try and flat-out install it while using the stock ROM, I get "application not installed". If I try to adb install it I get: Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]

If I place the apk file manually in the location for system apps it won't show up and won't launch.

I want to stay on stock Android but also have STK installed because the provider I'll be using the phone on (WIND Mobile) makes use of the SIM menu to enable/disable certain features such as international roaming.
[G1 Android Development] Daneshm90:
Can u check ur log when installing the app ? see wht *specifically* its complaining about. Normally "application not installed" is ofcourse that an error has occured but also when a "system" version of the same app is already installed.
[G1 Android Development] Brut.all:
I think "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE" is straightforward: Android refuses to install apk with UID if it has different certs than already installed app.
[G1 Android Development] Daneshm90:
Oops, my bad skimmed over that. :o

Yup so u got 2 options,

1. Find all the apks that have the same uid and resign them with the same keys

2. Remove the uid from the manifest and hope it works

Brut, quick question : U planning on implementing a "system" mode for apktool where it keeps the certs intact or have u decided to leave that up to the user ? Im thinking of incorporating that into apk manager (if system chosen, it backsup meta-inf and restores after apktool has compiled the apk. Also to check if the manifest.xml has been modified or not, if it hasnt then no warning, otherwise tell user to push while in recovery).
[G1 Android Development] Brut.all:
I didn't decide yet how to do that exactly.
[G1 Android Development] cmstlist:
Okay well what you've said so far makes some sense to me. The end goal is just that I'd like to have SIM Toolkit on my N1 while keeping my stock ROM. Or alternately, a program that does exactly the same thing as STK but can be installed on my N1 without trouble.
[G1 Android Development] rfgamaral:
Hi people, I'm having a little that hopefully you guys can help me out with...

I'm using Apktool to do some changes to HtcDialer.apk and HtcContacts.apk, both shared the same user id, which is

android.uid.shared

. After my changes, I repacked and signed those files as usual.

Then, I looked for all files that shared the same user id and signed them too, the ones I found are:

- ApplicationsProvider.apk

- ContactsProvider.apk

- GlobalSearch.apk

However, this is not working... Here's an excerpt of logcat:

I/PackageManager( 97): /system/app/HtcDialer.apk changed; collecting certs
D/dalvikvm( 97): GC freed 3727 objects / 329264 bytes in 117ms
D/dalvikvm( 97): GC freed 3730 objects / 323488 bytes in 120ms
E/PackageManager( 97): Package com.android.htcdialer has no signatures that match those in shared user android.uid.shared; ignoring!
W/PackageParser( 97): No actions in intent filter at /system/app/HtcContacts.apk Binary XML file line #402
W/PackageParser( 97): No actions in intent filter at /system/app/HtcContacts.apk Binary XML file line #407
W/PackageParser( 97): No actions in intent filter at /system/app/HtcContacts.apk Binary XML file line #412
I/PackageManager( 97): /system/app/HtcContacts.apk changed; collecting certs
D/dalvikvm( 97): GC freed 2277 objects / 325400 bytes in 125ms
E/PackageManager( 97): Package com.android.htccontacts has no signatures that match those in shared user android.uid.shared; ignoring!
D/dalvikvm( 97): GC freed 12521 objects / 838128 bytes in 129ms
I/PackageManager( 97): /system/app/GlobalSearch.apk changed; collecting certs
E/PackageManager( 97): Package com.android.globalsearch has no signatures that match those in shared user android.uid.shared; ignoring!
D/dalvikvm( 97): GC freed 11545 objects / 672944 bytes in 133ms
I/PackageParser( 97): com.htc.fieldtest: compat added android.permission.WRITE_EXTERNAL_STORAGE android.permission.READ_PHONE_STATE
I/PackageManager( 97): /system/app/ContactsProvider.apk changed; collecting certs
E/PackageManager( 97): Package com.android.providers.contacts has no signatures that match those in shared user android.uid.shared; ignoring!
W/PackageParser( 97): No actions in intent filter at /system/app/Bluetooth.apk Binary XML file line #114
I/PackageManager( 97): /system/app/ApplicationsProvider.apk changed; collecting certs
D/dalvikvm( 97): GC freed 6220 objects / 400640 bytes in 136ms
E/PackageManager( 97): Package com.android.providers.applications has no signatures that match those in shared user android.uid.shared; ignoring!
D/PackageManager( 97): Scanning app dir /data/app

I'm trying to sign only what's really needed... I mean, all my apks are left untouched from the original ones (with classes.dex inside) and I only sign those that I modified and shared the same user id. This to say that I previously signed every single apk and this problem didn't occur.

Which is weird and it means I'm missing signing something... Logcat doesn't show what and I'm already signing all apks that share the same user id.

What could it be? Any ideas?
[G1 Android Development] Daneshm90:
Nazgulled try this :

Backup the meta-inf folder of the apk ur modifying. After u've recompiled ur modified apk, place that meta-inf folder back inside the apk. Now if u've modified the manifest.xml then u'll have to push the file back onto ur phone either when in recovery or by doing

adb shell stop
<push the file to ur phone>
adb shell start

If u havent modified the manifest.xml then you can push it while core is running and it should work fine.

Remember, theres almost never a reason u should resign system apk.
[G1 Android Development] raspdeep:
any help or pointer in the right direction?
[G1 Android Development] rfgamaral:
@Daneshm90

Actually, the only thing I'm changing is the AndroidManifest.xml file...

Basically what you are suggesting is for me to update my modified files directly into the .apk without modifying any of SHA-1 hashes inside the the META-INF folder, right?

I understand that since these are system APKs, the hashes won't be verified and everything will work (or it's supposed to work). But isn't "weird" to have a MANIFEST.MF/CERT.SF file with wrong hashes?
[G1 Android Development] Daneshm90:
Nope, system apks are never verified against their certs, however its manifest is when the apk is swapped while core is running. So if ur editing the manifest.xml then make sure core is not running when u push the file back to ur phone. Best method as suggested by Brut, make an update.zip or push it manually in recovery.

As for *wierd*, well its not any weirder than themes since they do the exact same thing ;)