Android build.gradle 中的 proguard-android-optimize.txt 与 proguard-android.txt [英] proguard-android-optimize.txt vs proguard-android.txt in Android build.gradle

查看:189
本文介绍了Android build.gradle 中的 proguard-android-optimize.txt 与 proguard-android.txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 有关使用 build 缩小、混淆和优化发布版本的文档.Android 应用的 gradle.在文档的一部分中,proguard-android.txt 用作默认的 ProGuard 文件:

I was reading the docs about shrinking, obfuscating and optimising for a release build using build.gradle for an Android app. In one section of the docs, proguard-android.txt is used as the defauly ProGuard file:

android {
    ...
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }
}

在另一部分中,使用了 proguard-android-optimize.txt:

and in another section, proguard-android-optimize.txt is used:

android {
    ...
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
}

似乎没有解释这些之间有什么区别,我也找不到任何信息.有人可以解释一下区别是什么以及何时使用 proguard-android-optimize.txtproguard-android.txt?

There doesn't seem to be an explanation of what the difference between these are, and I can't find any information. Can someone explain what the differences are and when you would use proguard-android-optimize.txt vs proguard-android.txt?

谢谢:)

推荐答案

通过 此处.

优化:如果您不想优化,请使用proguard-android.txt 配置文件而不是这个,其中关闭优化标志.添加优化介绍某些风险,因为例如并非所有优化都由ProGuard 适用于所有版本的 Dalvik.以下标志转关闭各种已知有问题的优化,但列表可能没有是完整的或最新的.(算术"优化可以是如果您仅针对 Android 2.0 或更高版本使用.)请确保您如果你走这条路,请彻底测试.

Optimizations: If you don't want to optimize, use the proguard-android.txt configuration file instead of this one, which turns off the optimization flags. Adding optimization introduces certain risks, since for example not all optimizations performed by ProGuard works on all versions of Dalvik. The following flags turn off various optimizations known to have issues, but the list may not be complete or up to date. (The "arithmetic" optimization can be used if you are only targeting Android 2.0 or later.) Make sure you test thoroughly if you go this route.

此外,这个答案也很不错.

这篇关于Android build.gradle 中的 proguard-android-optimize.txt 与 proguard-android.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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