我正在 Android Studio 中开发一个应用程序,我想将混淆器添加到我的应用程序中。但我不知道该怎么办?我也想了解它的背景。谁能告诉我一些东西?谢谢。
最佳答案
在你的 gradle 文件中将 true
设置为 minifyEnabled
您可以定义是否在调试、发布或两者中启用 proguard
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
}
你也可以设置proguardFiles来配置他,检查这个site要查看有关它的文档,请看这个例子:
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/balysv/Documents/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-optimizationpasses 5
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
如果您想使用自定义字典进行代码混淆,请使用您的字典文件设置此配置:
-obfuscationdictionary proguard-dic.txt
-classobfuscationdictionary proguard-dic.txt
-packageobfuscationdictionary proguard-dic.txt
字典文件是一个简单的文本文件,其中包含您要用来混淆代码的标签,每行 1 个标签。
关于android - 如何准备混淆文件以及其中包含的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38213918/