Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle build resulting apk contains both obfuscated and non-obfuscated classes

When building my android project, I have added the following to the build.gradle file to enable proguard:

   buildTypes {
     release {
        runProguard true
        proguardFile 'proguard-project.txt'
        proguardFile '../common/proguard-shared.txt'
        proguardFile getDefaultProguardFile('proguard-android.txt')
     }
   }

Everything builds okay BUT when I disassemble the resulting dex file, it turns out that both the obfuscated and non-obfuscated files are there.

For example, both common.Base64 and common.a exist, the first is non-obfuscated, while the second is.

Not sure its related, but the project itself has a non-typical structure. This is a result of us having a large android code base with more than 40 android apps. We are trying to create a gradle based build flow side-by-side of existing eclipse based build.

If all goes well, we intend to change the file structure to be more native gradle, and start using flavours and build-types to have-away with many of the libraries we created to accommodate for the lack of flavours and such.

Project E above relies on a chain of libraries like that:

E -> D -> C -> B -> A

e.g. The E project depends on the library D which depends on library C ... all the way up to A.

like image 625
Guy Avatar asked Jul 22 '13 08:07

Guy


People also ask

What is an obfuscated APK?

The Android obfuscation is process of modifying an APK so that it is hard to understand and no longer useful to unauthorized parties(e.g hackers) but remains fully functional. Obfuscated code can be more difficult for other people to reverse engineer.

Which of the following is the Android obfuscation tool?

Obfuscapk is an open-source automatic obfuscation tool for Android apps that works in a black-box fashion (i.e., it does not need the app source code). Obfuscapk supports advanced obfuscation features and has a modular architecture that could be straightforwardly extended to support new obfuscation techniques.


1 Answers

After looking into this, I found out that this is a problem if you first build without proguard enabled and then build it with it enabled. This is due to the incremental mode of dex.

You can do a clean build after enabling proguard and it'll fix this.

Edit: I previously indicated that you can disable incremental mode in dex, but it turns out that actually doesn't help!

like image 161
Xavier Ducrohet Avatar answered Oct 06 '22 01:10

Xavier Ducrohet