Proguard不会混淆类名,只会混淆方法 [英] Proguard doesnt obfuscate Class name, only methods are obfuscated
问题描述
我尝试在android studio中使用Proguard,但似乎Proguard不会混淆类名,例如,我的应用程序结构和配置:
I try using Proguard in android studio, but seems like Proguard is not obfuscating the class name, for example, my app structure, and the config:
和配置
但是当我尝试在应用程序中触发异常时:
but when i try trigger the exception in the app:
该异常在ADB控制台中列出:
the exception is listed in ADB console:
仅对方法进行了混淆,而对MainActivity.class则没有混淆
only the methods are obfuscated, the MainActivity.class is not
推荐答案
这是预期的行为,因为该类是活动!
This is an expected behaviour because the class is an activity!
AndroidManifest.xml 中提到的所有类都必须保留其名称(活动,服务,提供者,接收者,应用程序,工具).否则系统将无法找到它们.
All classes that are mentioned in AndroidManifest.xml have to keep their names (activities, services, providers, receivers, application, instrumentation). Otherwise the system won't be able to find them.
Gradle构建会自动为ProGuard配置生成一些规则以实现此目的.它会扫描AndroidManifest.xml并为在那里找到的每个类添加规则.
Gradle build automatically generates some rules for your ProGuard configuration to achieve this. It scans AndroidManifest.xml and adds rules for each class found there.
如果要查看所有使用的规则,请将此行添加到ProGuard规则中:
If you want to see all the rules that are used, add this line to your ProGuard rules:
-printconfiguration "build/outputs/mapping/configuration.txt"
它将创建包含所有规则的configuration.txt
文件.
It will create configuration.txt
file containing all the rules.
应该是这样的:
# view AndroidManifest.xml #generated:50
-keep class com.github.browep.proguard.MainActivity {
<init>(...);
}
这篇关于Proguard不会混淆类名,只会混淆方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!