Understanding output files nomenclature

60 views
Skip to first unread message

Roger Ribas Manero

unread,
May 27, 2014, 10:07:54 AM5/27/14
to apk...@googlegroups.com
Hello to every one,

I've tested the Apktool with several Android applications and there are two cases in which I can't understand the nomenclature of the output files.

Firstly, let's suppose the application has a certain class MyClass.java. Therefore, the Apktool should output a smali/.../MyClass.smali file where I should be able to see something like .source "MyClass.java" in the top of it. However, some times I see that even having the same ".source", MyClass.java is splited into MyClass$1.smali, MyClass$2.smali etc. I can't understand why is that happening.

Secondly, I've noticed that certain classes', methods' and directories' names are replaced by single characters. Hence, I can find a.smali, b.smali files or directories a, b etc. Why is that happening? Is there any way to understand where these files come from? I've noticed that all those methods that don't belong to the Android API are lost. However, the methods defined in third-party libraries, such as AdLibraries, are not lost although they don't belong to the Android API. Could this be related to the fact that you import those libraries into your project?

Thank you very much for your time, I really appreciate your answers.

Kind regards,
Roger

Ryszard Wiśniewski

unread,
May 27, 2014, 11:04:15 AM5/27/14
to apk...@googlegroups.com

Both of them aren't caused by apktool nor smali, but what you see is actually a real content of the application.

First are anonymous classes - feature of Java. If you create e.g. inner Foo class in the outer Bar class then java compilator will generate a regular class with Bar$Foo name. And if you instantiate an anonymous class, its inner name will be auto-generated as next available number.

Second is caused by obfuscators, tools used by application developers - most probably Proguard. It replaces all class, method and field names with "a", "b", "c", etc. to make the code much harder to read.

--
You received this message because you are subscribed to the Google Groups "apktool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apktool+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roger Ribas Manero

unread,
May 27, 2014, 11:17:25 AM5/27/14
to apk...@googlegroups.com
Dear Ryszard,

Thank you very much for your reply. I would like to think that obfuscation tools are used to obfuscate the code written by the developer, hence, it shouldn't obfuscate the external libraries. However, sometimes I find obfuscated code outside the application package. Therefore, could we conclude that some times the obfuscation tools are applied to all the source code?

Thank you again and sorry for my newbie questions.

Regards,
Roger

Ryszard Wiśniewski

unread,
May 27, 2014, 12:25:15 PM5/27/14
to apk...@googlegroups.com

It depends on the configuration of the obfuscator. In Android all included libraries are merged into the code of the application itself, so nearly everything can be obfuscated. But don't have to,  usually not all information is obfuscated. For example names of some classes can't be obfuscated, because they're referenced by name in XML files. Sometimes you will see the structure of class packages and sometimes almost all classes will be moved to the root. It's all about the configuration.

Roger Ribas Manero

unread,
May 27, 2014, 12:41:07 PM5/27/14
to apk...@googlegroups.com
Okay I understand, thank you very much for your time.

Roger
Reply all
Reply to author
Forward
0 new messages