我看到 Android Plugin for Gradle 有一个 minifyEnabled
属性以及一个 useProguard
属性,如下:
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?
引用自 tools.android.com:
内置收缩器
Android Plugin for Gradle 2.0 版附带一个实验性的内置代码收缩器,可以代替 ProGuard 使用.这内置收缩器支持快速增量运行,旨在加快向上迭代周期.可以使用以下代码启用它片段:
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')
}
}
}
内置的shrinker只能去除死代码,不会混淆或优化.它可以使用相同的文件进行配置ProGuard,但会忽略所有与混淆或优化.
与 ProGuard 不同,我们支持将内置收缩器与Instant Run:视项目而定,可能会显着降低初始构建和安装时间.任何可以访问的方法代码更改后将显示为新添加到程序中,并且防止 Instant Run 热插拔.
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"和“minifyEnabled"有什么区别?和“useProguard"在 Gradle 的 Android 插件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!