如何在 Android Studio 中使用 ProGuard?

问题描述:

这是我在 Android Studio 中的第一个项目,我的应用程序代码没有被混淆.我在 build.gradle 文件中使用这个配置:

This is my first project in Android Studio, and the code of my apps are not obfuscated. Im using this configuration in build.gradle file:

我正在使用 Build > Generate Signed APK... 并选中 Run Proguard.而且,当我使用 Apk_OneClick.v4.2 进行测试时,我的代码完全易于阅读:

I'm using the Build > Generate Signed APK... with the Run Proguard checked. And, when I have tested using the Apk_OneClick.v4.2, my code is completly easy to read:

请帮帮我.:(

您可能实际上并未通过签名向导对 APK 的发布版本进行签名.您可以使用以下命令从命令行构建发布版 APK:

You're probably not actually signing the release build of the APK via the signing wizard. You can either build the release APK from the command line with the command:

./gradlew assembleRelease

或者您可以从 Build Variants 视图中选择发布变体并从 GUI 中构建它:

or you can choose the release variant from the Build Variants view and build it from the GUI: