tags:

views:

122

answers:

2

Hi,

Kindly provide me the steps to obfuscate an Android application from Eclipse IDE. Is Proguard jar best for this obfuscation purpose or do we have better obfuscator?

Warm Regards,

CB

A: 

As the code is compiled into bytecode, you don't need to obfuscate the code itself. Your obfuscated code can be also decompiled like any other code and the result will be nearly exactly the same: obfuscated...

[update] APK file before test: 254264 Bytes

Test 1:

I have made a short test by adding 5000 LOC with this:

int myVarhkjdsfhgcsdfjhgcnsdfhgcsnfdhgcnsdfiughcndsfgcnfdsghcnfdsghcsdfhcndsfkgchsd = 1;
myVarhkjdsfhgcsdfjhgcnsdfhgcsnfdhgcnsdfiughcndsfgcnfdsghcnfdsghcsdfhcndsfkgchsd++;
// up to 5000LOC

APK file size: 254571 (307 Bytes more than the basic apk)

Test 2:

Removed the spaces done for codeformating (8 spaces a line)

APK file size: 254571 (no changes to test 1)

Test 3:

Renamed the var into a shorter one

int test = 1;
test++;
// up to 5000LOC

APK file size: 254512 (248 Bytes more)

Testresult:

  • Spaces have no influence
  • variable names barely (59 Bytes saved by much shorter variable name)

Byte code is a highly optimized code, I doubt you really need to obfuscate your code to improve the file size. The best way to do that is to write negative code (search on SO if you don't know what it is)

WarrenFaith
In case of mobile application , code obfuscation will help in decreasing the size of the application other than the functionality of making a code a bit difficult to decompile.
updated my answer with a short test i have done
WarrenFaith
Android themselves advocate obfuscating (at least for licensing): http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html
Christopher
Kindly check the following excerpt taken from the FAQ section of the Proguard site Java source code (.java files) is typically compiled to bytecode (.class files). Bytecode is more compact than Java source code, but it may still contain a lot of unused code, especially if it includes program libraries. Shrinking programs such as ProGuard can analyze bytecode and remove unused classes, fields, and methods. The program remains functionally equivalent, including the information given in exception stack traces.
It may have a virtually negligible impact on size/performance, but there's still merit to obfuscating as it makes the modification of your decompiled app significantly more difficult.
Blumer
A: 

Just in the last couple days, they've given instructions on how to do this in the Android Developers Blog: http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+blogspot%2FhsDu+%28Android+Developers+Blog%29

Blumer
And yes, the benefits of it reach far beyond the size stuff that's being mentioned. It will make your decompiled bytecode more difficult to reverse engineer. Certainly not impossible, but it will replace your descriptively-named variables and functions with meaningless strings.
Blumer