yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] mrme01:
What? Im new to this, give me a break...
[G1 Android Development] canadiancow:
Removing a dialog is going to require development.
[G1 Android Development] mrme01:
I thought it would be an edit and a repack. Ok so I guess I need to load the extacted files into the SDK?
[G1 Android Development] canadiancow:
Errmm... I don't really see how you'd load anything into the SDK. :confused:

You're going to need to edit the smali file(s) to make the change, then rebuild.
[G1 Android Development] Brut.all:
Hmm... dialog removing should be possible at layout level (XMLs) or am I wrong?

@mrme01

If it is really necessary to edit app code, as canadiancow said, then this doesn't make any sense. Code is probably odexed, understand it as "encrypted", so it will be hard to decode it. And even if you succeed, then you will get code looking like this:

http://code.google.com/p/smali/source/browse/trunk/examples/RecursiveAnnotation/Main.smali

It is really advanced thing, sorry.
[G1 Android Development] canadiancow:
I assumed that somewhere in the code was something like an AlertDialog.Builder that was being used to display it. I could be wrong.
[G1 Android Development] olearyp:
Even if that weren't the case, simply removing the layout resource would be asking for either an instant FC or failure to build R, wouldn't it? The raising of the alert would also need to be replaced with the desired effect of the button press, which probably means moving an anonymous listener class around.
[G1 Android Development] Brut.all:
I prefer to move as much as possible from code to config files (XML), even event listeners are configurable. I forgot that other people may have different preferences ;-) R is totally useless, because we don't have Java code - apktool doesn't even generate it ;-)

But... could we hide some view instead of removing it? Something like height="0"? I don't really know :-)
[G1 Android Development] olearyp:
Re: R: This is what is known in the industry as a "brain fart." :) Though the effect is still there--the smali code which calls up the dialog will refer to a resource ID that won't exist anymore, right?

You could certainly have an empty View, but tbh I have no idea what happens if you actually construct such a thing.
[G1 Android Development] mrme01:
I have uploaded the extracted files :)

http://www.4shared.com/file/JTX_kmV-/PowerOffContents.html
[G1 Android Development] Brut.all:
Sorry for no reply, I just missed your post :-/

Are you sure you know, how to sign resources properly? I'm asking cause I had problems with testing framework-res.apk modifications. I got boot loop, find an error in logcat about wrong certificates or something like that. prash helped me out with this :-)
[G1 Android Development] Royal2000H:
Hey

I'm trying to edit some of the code in an apk and unfortunately it's not working.

I decoded using apktool, made my change in the smali file. Built the apk. Put it on my phone.. and then I get "Installing..." "Application not installed".

Even if I decode. Make NO changes. Build. I get the same error.

Any help?

EDIT: nevermind. I just needed to sign it.

------------------

EDIT 2:

I know this isn't really related to your tool...but if you could help...

Say I have a boolean bit in v2. How do I flip the bit?

invoke-virtual {v2}, Lcom/google/gson/JsonElement;->getAsBoolean()Z

move-result v2

so if v2 is false... how do I make it true??

If there's no way to flip... since I want it to be true, is there any way to just make v2 true?

I'm not experienced with these codes...

EDIT 3:

Nevermind... figured it out.

In case anyone is wondering:

const/4 v2, 0x1
[G1 Android Development] bitizx:
hello everyone

I'm a novice here.

I just wrote a wrapper class called ApkToolEx:)

It is poor but is lightweight.:D

I attached the source, maybe it is helpful for sb. I think.

You can use this class in your program like below

ApkToolEx decoder = new ApkToolEx(new File("C:/th.apk"));
// decode XML
decoder.decodeXML2File("AndroidManifest.xml", new File("C:/AndroidManifest.xml"));
decoder.decodeXML2File("res/drawable/custombutton.xml", new File("C:/1.xml"));
or
decoder.decodeXML2File("@drawable/custombutton", new File("C:/1.xml"));

// decode a XML file to string
s = decoder.decodeXML2Str("res/drawable/custombutton.xml");
or
s = decoder.decodeXML2Str("@drawable/custombutton");

// get a string, boolean, int, color or float
String s = decoder.getScalarValue("@string/app_name");

// extract a raw file
decoder.extractRawFile("@drawable/icon", new File("C:/1.png"));

To Brut.all

Is it a bug?

when I decode the whole apk, all *.9.png files becomes to *.png, the .9 is missing.
[G1 Android Development] Brut.all:
Nice :-D

Was it worth to spend time analyzing .class files? :-)

As you have noticed apktool is just a CLI frontend to androlib and second one is much more capable, has much more flexible API, than apktool. It could be used to other tasks than apktool supports :-)

http://code.google.com/p/android-apktool/issues/detail?id=2
[G1 Android Development] Brut.all:
1.1.0 is here! :-)

This smali debugging isn't that I showed on video few weeks ago, but you should be satisfied ;-)

I thought earlier that debugger must know class and member declarations to watch variables when debugging. That is why I decided to decode these declarations to Java form. Recently I have found that debugger could read most of the data from memory, so it doesn't require sources. Of course I have used that fact ;-) Smali debugging generates only minimal set of Java code.

Comparing to Java decoding (that from video) this has pros and cons: it doesn't support Java-smali mixing, but it should work perfectly fine for any apk that smali supports! I have even debugged step by step obfuscated Google Maps! :-) Java decoding requires some time, it is and probably will be quite advanced and complicated feature. Smali debugging is easy to use, it is definitely much more useful for real situations.

EDIT:

Ahh and I have succeed in rebuilding Rosie.apk :-) I didn't test it, cause I don't have device with Sensie UI, but it's quite probable, that it works fine :-)
[G1 Android Development] otto888:
Nice! I can confirm that the apps I decompile that got stuck compiling on 1.0 are no longer getting stuck. :D
[G1 Android Development] canadiancow:
Sounds awesome. I'm going to do some Maps debugging...see if I can get that damn street name to show up or something.

Edit:

C:\Users\Scott\Documents\android\apktool\maps>apktool d -d maps4.1.0.4126-brut6.apk decoded
I: Baksmaling...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: File already exists: decoded\smali\x\g.java
at brut.androlib.Androlib.decodeSourcesSmali(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.androlib.AndrolibException: File already exists: decoded\smali\x\g.java
at brut.androlib.src.SmaliDecoder.decodeClassDefItem(Unknown Source)
at brut.androlib.src.SmaliDecoder.decode(Unknown Source)
at brut.androlib.src.SmaliDecoder.decode(Unknown Source)
... 4 more

Edit2:

Windows files are case insensitive. I already had a G.java. You still confident this will work on Windows?

Edit3:

I cannot get the damn debugger to attach to brut.googlemaps :(
[G1 Android Development] HomerSp:
Awesome, can confirm that system apk's now decompile and compile correctly!

Edit: Have a future request, would it be possible to implement something so you can use external framework and resource files? I realize I can just replace the files from apktool.jar, but would be great if you could use an external file
[G1 Android Development] Brut.all:
:-D

Baksmali is affected too. We could ask JF about fix, but I doubt he will add some automatic refactoring mechanisms (won't be easy to fix this) for a rare case of code obfuscation + Windows.

I can't do anything with that, sorry.

Did you ever manually attached debugger to Android app? There should be no difference, apktool just modifies some code, but has nothing to do with debugger attaching. You could watch my video about Java decoding - there I have manually attached debugger.

And I spotted your edits accidentally. It's not good to edit posts after several hours ;-)

Thanks for confirmation. I'm nearly blind when it comes to HTC apps - I can't test them.

http://code.google.com/p/android-apktool/issues/detail?id=27
[G1 Android Development] ali3nfr3ak:
hi , awesome tool, i am having trouble rebuilding the apk that i have decoded.

seems to get stuck here:

I: Checking whether sources has changed...

I: Smaling...

I: Checking whether resources has changed...

I: Building resources...

Basically what i have done is downloaded apktool-install-windows-2.1_r01-1.zip apktool-1.1.0.tar and extracted them both to windows/system32 , have not set a path ... Do i need to? if so how?, I am trying to rebuild desire (HTC) apk's , namely com.htc.WeatherWidget.apk .... any ideas...yes im a noob lol
[G1 Android Development] Brut.all:
Are you sure you are using 1.1.0 version? Type "apktool" and look at the top of usage help.

There was an issue, but I thought I fixed it in v1.1.0 :

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

I have this WeatherWIdget.apk file (md5sum: f7a1fc553ff121bae8bd43e23e5a3794) and I don't have any problems with it. I will try on Windows.
[G1 Android Development] Brut.all:
If you are using smali debugging feature, then you definitely should update.
[G1 Android Development] ali3nfr3ak:
hi saw that u have updated the version so i downloaded the new 1.1.1

md5 3CEBC245C3436981E15841FBDDCDA996

then i typed apktool and got this

C:\>apktool

Apktool v1.0 - a tool for reengineering Android apk files

Copyright 2010 Ryszard Wi?niewski <brut.alll@gmail.com>

these are the commands im using

c:\apktool d com.htc.WeatherWidget.apk c:\apk

c:\apktool b c:\apk

my weatherwidget is from pauls desire rom and has

md5 BF361F72F8635A20F11CD1F56A15FA29
[G1 Android Development] Brut.all:
As you can see you are using v1.0 . I don't know, why, just check where you placed downloaded files.

And now I have time to get some fun with smali debugging and it is just *awesome*. One hour with it and I know, where in GM street name is set - it would took me a week or more without debugging :-D
[G1 Android Development] HomerSp:
Sounds good, would love a feature to use external framework files. But if you don't feel like it that's fine :)
[G1 Android Development] chunan93:
I just used apktool v1.1.1 on framework-res.apk from CM v5.0.7-test1.

Decode seemed fine but some errors happened when build even i did nothing on decoded application.

To decode/build other apks did work. Did i do something wrong?
[G1 Android Development] Brut.all:
You did everything ok:

http://code.google.com/p/android-apktool/issues/detail?id=30
[G1 Android Development] canadiancow:
Why are you using apktool on open source software?
[G1 Android Development] zippy-man:
Great Work Here. I cant thank you enough for this app.

I did run into a problem with an apk from HTC. It seems to be working now on most but some still fail like this one. Maybe the resources where not put in?

LinuxMint new # apktool d FriendStream.apk ./out
I: Baksmaling...
I: Decoding resource table...
I: Decoding resources...
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x02010028
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x02010028
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x02010026
I: Copying assets and libs...

Here is a download to the apk for you to look at if needed

Also if you need more info please let me know
[G1 Android Development] myn:
I'm not sure exactly what the problem is but I am having a problem editing a Donut (1.6) Contacts.apk.

I've done the following:

Decode:

D:\Test>apktool.bat d Contacts.apk ./out
I: Baksmaling...
I: Decoding resource table...
I: Decoding resources...
I: Copying assets and libs...

A new out directory is created (out) and the source files are available. For sake of testing I changed 0 files in this new directory.

Build:

D:\Test>apktool.bat b -f -d out
I: Smaling...
I: Building resources...
aapt: warning: string 'recentCalls_removeAllFrom' has no default translation in
D:\Test\out\res; found: de
aapt: warning: string 'summary_contacts_show_pic' has no default translation in
D:\Test\out\res; found: de
I: Building apk file...

a new apk is created in ./out/dist

To sign I've tried RightClick Sign, AutoSign and also used MOTODEV studio's (Eclipse) APK signing tool.

In all cases Contacts.apk cannot be installed on my phone.

I've attached the source Contacts.apk I was trying to decode/rebuild below.

Any help would be greatly appreciated.

Thanks
[G1 Android Development] HomerSp:
Did you try not signing the apk and just make the changes?
[G1 Android Development] olearyp:
Install it with 'adb install' and post the error message.
[G1 Android Development] Brut.all:
@zippy-man, @tristan202

Thanks for report and link to file - I'll look into it.

What is the error, if you try to install it through adb? You could also look into logcat.

Did you uninstalled original Contact.apk first? You can't update/reinstall original file to your version, because they are signed with different keys. You must uninstall & install.
[G1 Android Development] canadiancow:
Brut.all, one thing that's been happening with all your apktool's since I first tried (and still happens with 1.1.1) is bothering me.

If I decode and rebuild your modified Maps application, all the layouts get screwed up. Any ideas? I can post a screenshot if necessary.
[G1 Android Development] Brut.all:
It's 9-patch issue, I know of that. This is, what is going on:

Original sources - 9-patch data stored as one-pixel border

Compiled app - 9-patch data serialized and stored in image binary (aapt does that)

(for now apktool can't decode compiled 9-patch to border format)

(if aapt find *.9.png file without border, it will throw error)

when decoding apktool modifies names of all *.9.png files to normal *.png . It also copies all these files to special 9-patch directory

aapt will build these files, because they are normal *.png . It will remove 9-patch data from them

apktool replaces files generated by aapt with these from 9-patch directory

everything runs ok, because 9-patch images don't have to be named as *.9.png . Name is important in sources - to let aapt know, what to do - but after building only binary data matters

if you then decode this apk, apktool won't recognize 9-patch images, because they are *.png . When building aapt will eat 9-patch data from them and you will get visual problems

There are 2 solutions:

Temporary: let apktool store list of 9-patch images when building an apk.

add support for decoding 9-patch data

First should be quite easy to do, I didn't add such feature, because second one is a must and reediting already rebuilt apk isn't common case.
[G1 Android Development] Brut.all:
Ahh and you could workaround this, type something like:

$ apktool d maps.apk maps
$ cd maps
$ mkdir -p 9-patch/res
$ cp -r res/drawable* 9-patch/res/

You got and idea :-)
[G1 Android Development] fridlack:
Trying to change name to youtube.apk from donut to get donut and eclairs apks in the same instalation

I decoded Youtube.apk

apktool d Youtube.apk Youtube

Then modified AndroidManifest.xml and changed all "com.google.android.youtube" for "com.google.android.youtubemod"

Coded again

apktool b Youtube

Signed apk, instaled in phone, then trying to run app and get FC :(

What am i forggeting?

Thanks in advance!
[G1 Android Development] Brut.all:
Just look into logcat. Changing package name isn't that easy - there are several other things, that must be modified for this, e.g.:

sharedUserId

content provider authorities

permission names if application defines some

xmlns:app namespaces if app uses its own XML attributes

maybe there are some Intents in a code using full package name

etc.
[G1 Android Development] canadiancow:
Thanks for the explanation. I'm not that motivated anymore, given your success with "street names", but I'm sure you'll add support when you have time.
[G1 Android Development] myn:
I have a hard enough time in Eclipse with full source changing the package name nevermind through a decoded file.

Good luck with this. I would stear clear of it.
[G1 Android Development] olearyp:
every smali file's package declaration and in the code, their references to other objects in the package?
[G1 Android Development] Brut.all:
No, fortunately not. App package name has nothing to do with Java packages.
[G1 Android Development] olearyp:
Oh, that's good; it's the ADT default to match them but I wasn't sure if it mattered to the system somehow. Thanks!
[G1 Android Development] Nalorokk:
D:\android\proc>apktool d HTC_IME.apk out
I: Baksmaling...
Exception in thread "main" org.jf.dexlib.DexFile$NoClassesDexException: zip file
HTC_IME.apk does not contain a classes.dex file
at org.jf.dexlib.DexFile.<init>(Unknown Source)
at org.jf.dexlib.DexFile.<init>(Unknown Source)
at brut.androlib.src.SmaliDecoder.decode(Unknown Source)
at brut.androlib.src.SmaliDecoder.decode(Unknown Source)
at brut.androlib.Androlib.decodeSourcesSmali(Unknown Source)
at brut.androlib.ApkDecoder.decode(Unknown Source)
at brut.apktool.Main.cmdDecode(Unknown Source)
at brut.apktool.Main.main(Unknown Source)

D:\android\proc>

Not Work on all .apk
[G1 Android Development] Brut.all:
Of course not.

But this error above is user error: it's quite logical that if apk doesn't contain app code (classes.dex), then it shouldn't be decoded (-s switch), isn't it?
[G1 Android Development] Nalorokk:
But how to build it without code?
[G1 Android Development] Brut.all:
Apk don't have to contain any code at all. It may be pure-resources, as framework-res.apk is.

About your situation: when installing protected app or when installed app is optimized, code and resources are separated. Resources are in standard apk, but code is in /data/dalvik-cache/. On HTC devices all system apps are optimized :-)

If you want to modify some resources of HTC_IME just for yourself, then screw code: add "-s" switch, modify, build and push built apk - code will be still in /data/dalvik-cache/, so it should work. But if you want to modify sources and/or upload your mods to someone else, then you should read about deodexing and I warn you in advance, that this is more advanced thing.
[G1 Android Development] Nalorokk:
I build .apk without code and he has less size than original .apk (200kb), and it do not work on my HTC Hero. I just overwrite original .apk by cp in /system/app
[G1 Android Development] myn:
Since Contacts is a system level apk I mounted /system as rw and rm /system/app/Contacts.apk then proceeded to adb install my signed and altered Contacts.apk to /system/app and here was the response. Pretty self explanatory.

D/dalvikvm( 218): GC freed 15540 objects / 847808 bytes in 262ms
W/PackageManager( 218): Trying to update system app code path from /system/app/
Contacts.apk to /data/app/com.android.contacts.apk
E/PackageManager( 218): Package com.android.contacts signatures do not match th
e previously installed version; ignoring!
W/PackageManager( 218): Package couldn't be installed in /data/app/com.android.
contacts.apk
D/AndroidRuntime( 870): Shutting down VM
D/dalvikvm( 870): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 870): DestroyJavaVM shutting VM down
D/dalvikvm( 870): HeapWorker thread shutting down
D/dalvikvm( 870): HeapWorker thread has shut down
D/jdwp ( 870): JDWP shutting down net...
D/dalvikvm( 870): VM cleaning up

So I forced Contacts.apk via adb push into /system/app then cleared all data and restarted fresh with the new Contacts.apk in place..

The first thing I noticed after going through the google setup screens is that the Contacts and Dialer icons are not on the Home Screen nor in the Launcher.

Also, trying to launch/install /system/app/Contacts.apk via Astro File Manager the Summary and Details tabs are empty except for text in the Details tab: Could not open/system/app/Contacts.apk as APK file.

Got some ideas? Have you been successful decoding/rebuilding Contacts.apk? As I mentioned. If I just decode and build then sign it still doesn't work so I don't think it has anything todo with my alterations.

Thanks again
[G1 Android Development] olearyp:
Still looks like a signature error. Go find and use testsign.jar, or download this keystore and use the key with alias "platform" with jarsigner and the -keystore option pointing at the file. Just do it from the command line, that way you can look. You can verify the signature against the keystore as well using jarsigner to ensure that you did, in fact, sign it correctly.
[G1 Android Development] glock2how:
Autor, this is cool program, but it cant work with Mytouch slide 3g framework! I try translate htc clock widget to another language (add dir /values-ru in dir/res/) but widget cant start on my htc hero with slide 3g ROM. Apk decod and build succses no errors.

This my steps:

1) decode apk

2) add values-ru dir

3) build apk

4) I copy sertificate (dir META-INF), from original apk.

5) I sign apk and install.

What I do wrong? please help, if you help i can localizate Mytouch slide 3g ROM to another language.

Sorry my bad English I from snowly Russia.
[G1 Android Development] Brut.all:
You can't do that :-) Assumption of certification is that certificates are connected with archive contents, so if contents will change then certificates must too.

I'm not sure about how to do it for HTC device, I don't have one. I think you should use testsign tool, but I don't want to mislead you.
[G1 Android Development] glock2how:
I simple decode and build original apk and... apk don't work
[G1 Android Development] Brut.all:
Most likely for the same reason. Even if you didn't touch anything, new apk is binary different.

You don't sign logical content, but binary data :-)
[G1 Android Development] Daneshm90:
Hey been using apktool a lot :) Awesome work on it. Any chance you can incorporate the signing of the apk into your jar file ?
[G1 Android Development] Brut.all:
Yeah :-)

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

But for know I'm working on Google Maps modifications. It's hard to have time for all of your children ;-D
[G1 Android Development] myn:
Awesome! signing would really be the icing on the cake :)

Can't wait.
[G1 Android Development] glock2how:
Please, I not understand, I sign apk (use androsign on Win7x64).
[G1 Android Development] tristan202:
Any news on rebuilding android 2.1 framework-res.apk? Have some mods I'd really like to get implemented.
[G1 Android Development] canadiancow:
You know, you can just download, modify, and compile the source. It's a hell of a lot easier than using apktool.
[G1 Android Development] tristan202:
Not if I don't know where to get the source, and how to compile it.
[G1 Android Development] canadiancow:
http://source.android.com/download
[G1 Android Development] myn:
I thought I'd share this useful tip.

If you are editing just XML files and they live in /res of the apk, you can rebuild them with your changes using apktools and then take the newly compiled xml files and deposit them into the original APK by using your favorite archiving tools (winrar, 7zip).

This is what ultimately worked for me and my problem with Contacts.apk being signed correctly. I just edited the xml, rebuilt and injected the changed xml into the original apk. Works perfectly.
[G1 Android Development] tristan202:
I have done that before, but the ones I have edited now is in the values folder.
[G1 Android Development] jgworks:
Awesome work Brut.all this thing is amazing. Any chance I could get the source code for this? I'd love to add a few things and push them back to you.
[G1 Android Development] Brut.all:
What things? :-)

Yeah, I planned to release sources somewhere around version 1.0, will do it, I promise ;-)