“minifyEnabled"和“minifyEnabled"有什么区别?和“useProguard

What#39;s the difference between quot;minifyEnabledquot; and quot;useProguardquot; in the Android Plugin for Gradle?(“minifyEnabled和“minifyEnabled有什么区别?和“useProguard在 Gradle 的 Android 插件中?)
本文介绍了“minifyEnabled"和“minifyEnabled"有什么区别?和“useProguard"在 Gradle 的 Android 插件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我看到 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 插件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)