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

查看:34
本文介绍了我应该使用 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 还有另外两个重要的功能:shrinking,它消除了未使用的代码,显然非常有用,同时也是优化.然而,优化使用 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

在您的 project.properties 文件中.由于您提到您使用 Android Studio 并且您没有这个文件,但是您被问及配置文件,请尝试选择 Android SDK 中的一个 (tools/proguard/proguard-android.txt).

in your project.properties file. Since you mention that you use Android Studio and you don't have this file, but you are asked about the config file, try selecting the one that is in the Android SDK (tools/proguard/proguard-android.txt).

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

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