是否可以在调试模式下使用 proguard? [英] Is it possible to use proguard in debug mode?

查看:37
本文介绍了是否可以在调试模式下使用 proguard?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 android 应用中,我想在启用 proguard 的情况下测试一些功能.

In my android app, i want to test some features with proguard on.

我不需要真正调试"它,但我希望 proguard 在我在 Eclipse 中运行时运行.我不想每次都导出二进制文件(因此,在发布模式下)并保存为 apk 并将其发送到设备进行测试.

I don't need to really "debug" it, but i want proguard to run when i hit run in eclipse. I don't want to export the binary every time (so, in release mode) and save as apk and get it to the device to test.

有没有办法以这种方式运行proguard?

Is there any way to run proguard in this way?

更新:

如果您使用Eclipse,这似乎是可能的;由于题名不包含Eclipse,因此该问题有多个正确答案.

It seems like this is possible if you are not using Eclipse; as question title does not include Eclipse, there are multiple correct answers to this question.

推荐答案

旧答案:

http://developer.android.com/tools/help/proguard.html

ProGuard 仅在您在发布模式下构建应用程序时运行,因此您在调试模式下构建应用程序时无需处理混淆代码.

当您在 release 模式下构建应用程序时,无论是通过运行 ant release 还是使用 Eclipse 中的导出向导,构建系统都会自动检查 proguard.config 属性已设置.如果是,ProGuard 会在将所有内容打包到 .apk 文件之前自动处理应用程序的字节码.在调试模式下构建不会调用 ProGuard,因为它使调试更加麻烦.

When you build your application in release mode, either by running ant release or by using the Export Wizard in Eclipse, the build system automatically checks to see if the proguard.config property is set. If it is, ProGuard automatically processes the application's bytecode before packaging everything into an .apk file. Building in debug mode does not invoke ProGuard, because it makes debugging more cumbersome.

更新:13-3-2016

使用新的 gradle 构建系统是可能的.您需要在 build.gradle 文件中将 minifyEnabled 设置为 true.通常,您在 release 模式下运行 pro-guard.还有其他可用的选项,例如缩小资源.你可以找到一些有用的信息@http://tools.android.com/tech-文档/新构建系统

It is possible with the new gradle build system. You need to set minifyEnabled to true in your build.gradle file. Generally you have pro-guard running in release mode. There are other options available like shrinking resources. You can find some useful info @ http://tools.android.com/tech-docs/new-build-system

也看看@

http://developer.android.com/tools/building/configuring-gradle.html

 android {
   ...
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
     debug {

        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
   }
 }

这篇关于是否可以在调试模式下使用 proguard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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