android - Android Plugin for Gradle 中的 "minifyEnabled"和 "useProguard"有什么区别?

标签 android gradle android-gradle-plugin build.gradle proguard

我看到 Android Plugin for Gradle 有一个 minifyEnabled 属性以及一个 useProguard 属性,如下:

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

这两个属性有什么区别?或者,更确切地说,每个的含义是什么?

最佳答案

引自 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.

关于android - Android Plugin for Gradle 中的 "minifyEnabled"和 "useProguard"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37007485/

相关文章:

android - 指定 Android 项目依赖项(在 Eclipse 中)

android - asyncTask 中的 ProgressDialog setProgress 和 setMessage 不起作用

android - 无法使用哈希字符串 '27.0.3' Android Studio 3.1.3查找目标

java - 在 gradle 中找不到用于测试任务的方法 useJUnitPlatform

android - Butter Knife - 在 Android lib 上注入(inject)

基于 Android 位置的提醒/事件?

android-maven-plugin:将proguard绑定(bind)到后期

java - Gradle 和 Spring 的几个模块

android - Android Studio中缺少与Gradle图标同步项目

android - 如何将增量构建添加到 Dagger 2