Proguard的不解不起作用 [英] 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'
}
#...
这是我ProGuard的文件:
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
我使用该命令倾倒所有dexed类:
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
和我仍然看到所有全包名称,如果我只是用grep的QQQ的我没有得到任何结果,因此看来,这两个规则 repackageclasses
和 flattenpackagehierarchy
似乎被忽略(我还只测试了该行之一来使用)。知不知道我错过了吗?
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?
推荐答案
哇,这了很长时间才解决。该butterknife规则打破了一切。我的解决办法是用grep是一个来自网页和如何一切工作正常。
Wow this took long to fix. The butterknife rules broke everything. My solution was to grep that one from the homepage and how everything works as expected.
下面是固定的规则:
# Butterknife
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
@butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
@butterknife.* <methods>;
}
# OrmLite uses reflection
-keepclassmembers class com.j256.** { *; }
-keep class my.package.name.database.** { *; }
-keep class com.j256.**
#test
-repackageclasses 'qqq1'
-flattenpackagehierarchy 'qqq2'
-allowaccessmodification
-forceprocessing
这篇关于Proguard的不解不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!