問題描述
我看到 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模板網!