Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard obfuscating does not work

I'm trying to obfuscate my package names including that one of my used libraries.

I use this build config in my gradle file:

buildTypes {
    debug {
        versionNameSuffix "-Development"
        debuggable true
        runProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    #...

This is my proguard file:

# Butterknife
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}

# OrmLite uses reflection
-keepclassmembers class com.j256.** { *; }
-keep class my.package.name.database.** { *; }
-keep class com.j256.**

#test
-repackageclasses 'qqq1'
-flattenpackagehierarchy 'qqq2'
-allowaccessmodification
-forceprocessing

I'm using this command for dumping all the dexed classes:

7z x -aoa my.apk classes.dex && dexdump classes.dex | grep "Class desc" | less

And I still see all full package names if I just grep for "qqq" I get no results so it seems that both rules repackageclasses and flattenpackagehierarchy seems to be ignored (I also tested to use only one of that lines). Any idea what I missed?

like image 228
rekire Avatar asked Sep 26 '26 16:09

rekire


1 Answers

For library modules, it seems that the build system add "-keeppackagenames" by default which will lead to the package names not be obfuscated.

You can try using this WORKAROUND:

Add "-keeppackagenames !**" to disable -keeppackagenames being injected by the build system.

Via: https://code.google.com/p/android/issues/detail?id=67587

like image 109
Alan Zhiliang Feng Avatar answered Sep 28 '26 05:09

Alan Zhiliang Feng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!