我应该使用ProGuard吗? [英] Should I use ProGuard?

查看:96
本文介绍了我应该使用ProGuard吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android Studio中生成签名的APK,它为我提供了运行ProGuard的选项.它要求我提供配置文件的路径,但是我没有配置文件.如何创建一个?我应该完全使用ProGuard吗? 您可以并且容易解压缩不使用ProGuard的APK文件吗?

I want to generate signed APK in Android Studio and it offers me an option to run ProGuard. It asks me to give config file path, but I don't have config file. How to create one? Should I use ProGuard at all? Can you and is it easy to unpack APK file which don't use ProGuard?

感谢您的答复,但我找不到任何地方的proguard.cfg文件.我在项目的根目录中只有属性文件是local.properties文件,当我在Android Studio中打开它时,我得到了这一点:

Thank you for your answers, but I can't find proguard.cfg file anywhere. Only properties file I have in root directory of the project is local.properties file and when I open it in Android Studio I got this:

# This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.

# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C:/.../...

推荐答案

对Android应用程序进行逆向工程非常容易,因此,如果要防止这种情况发生,请使用ProGuard作为其主要功能:混淆.

It is quite easy to reverse engineer Android applications, so if you want to prevent this from happening, yes, you should use ProGuard for its main function: obfuscation.

ProGuard还具有其他两个重要功能:缩小,它消除了未使用的代码,显然非常有用,并且优化了.不过,优化是使用Java字节码运行的,并且由于Android在从Java字节码转换而来的Dalvik字节码上运行,因此某些优化不能很好地工作.因此,您应该在那小心.

ProGuard has also two other important functions: shrinking which eliminates unused code and is obviously highly useful and also optimization. Optimization operates with Java bytecode, though, and since Android runs on Dalvik bytecode which is converted from Java bytecode, some optimizations won't work so well. So you should be careful there.

Android网站上有有关如何使用proguard的说明.您需要检查的主要内容是线路是否正确

There are instructions on how to use proguard on the Android website. The main thing you need to check is that you have the line

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

文件中的

.由于您提到使用的是Android Studio,但没有此文件,但是系统询问您有关配置文件的信息,因此请尝试选择Android SDK(tools/proguard/proguard-android.txt)中的文件.

这篇关于我应该使用ProGuard吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆