“minifyEnabled”有什么区别?和“useProguard”在Android插件Gradle? [英] What's the difference between "minifyEnabled" and "useProguard" in the Android Plugin for Gradle?

查看:4532
本文介绍了“minifyEnabled”有什么区别?和“useProguard”在Android插件Gradle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到Gradle的Android插件具有 minifyEnabled 属性以及 useProguard 属性,如下所示:

  android {
buildTypes {
debug {
minifyEnabled true
useProguard假
}
释放{
minifyEnabled true
useProguard true
}
}
}

这两个属性有什么区别?或者说,每个人的含义是什么? 解决方案


$ b


内置缩放器

Android版插件for Gradle 2.0版附带一个实验性的
内置代码缩放器,它可以用来代替ProGuard。
内置收缩器支持快速增量运行,旨在加快迭代周期的
。可以使用以下代码启用它:
snippet:

$ p $ android $ {
uildTypes {
debug {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
code>

内置收缩器只能删除死代码,不会混淆或优化。它可以使用与
ProGuard相同的文件进行配置,但会忽略与混淆或
优化有关的所有标志。
ProGuard,我们支持使用内置收缩器和
Instant Run:根据项目的不同,它可能会显着减少
的初始构建和安装时间。任何在代码更改后变为可到达
的方法都会显示为新添加到程序中,
可防止即时运行热切换。


I see that the Android Plugin for Gradle has a minifyEnabled property as well as a useProguard property, as follows:

android {
    buildTypes {
        debug {
            minifyEnabled true
            useProguard false
        }
        release {
            minifyEnabled true
            useProguard true
        }
    }
}

What's the difference between these two properties? Or, rather, what's the meaning of each?

Quoting from tools.android.com:

Built-in shrinker

Version 2.0 of Android Plugin for Gradle ships with an experimental built-in code shrinker, which can be used instead of ProGuard. The built-in shrinker supports fast incremental runs and is meant to speed up iteration cycles. It can be enabled using the following code snippet:

android {
    buildTypes {
        debug {
            minifyEnabled true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt')
        }
    }
}

The built-in shrinker can only remove dead code, it does not obfuscate or optimize. It can be configured using the same files as ProGuard, but will ignore all flags related to obfuscation or optimization.

Unlike ProGuard, we support using the built-in shrinker together with Instant Run: depending on the project, it may significantly decrease the initial build and install time. Any methods that become reachable after a code change will appear as newly added to the program and prevent an Instant Run hotswap.

这篇关于“minifyEnabled”有什么区别?和“useProguard”在Android插件Gradle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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