未明确编写脚本的 buildType 的 minifyEnabled 的默认值是什么? [英] What is the default for minifyEnabled for buildType not explicitly scripted?

查看:43
本文介绍了未明确编写脚本的 buildType 的 minifyEnabled 的默认值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将几个 Eclipse 项目导入到 Android Studio (v1.1).

在原来的 Eclipse 环境中,他们使用 Proguard 作为发布模式.

在 Android Studio 环境中,这在 build.gradle 脚本中被转换为以下内容(由导入,而不是由我):

buildTypes {释放 {minifyEnabled trueproguardFiles 'proguard.cfg'}}

我理解这意味着release构建中,使用proguard.cfg启用Proguard的缩小".

然而,问题是 minify 似乎也在非发布版本(即调试)中发生!

这怎么可能?

调试版本的 minifyEnabled 的默认值是多少?

<小时>

更新 1: 感谢下面的回答,我现在知道默认值为 false.这意味着其他东西正在构建在调试版本中缩小的各种模块.

我发布了在调试版本中被缩小的模块之一的整个 build.gradle:

应用插件:'com.android.library'安卓 {compileSdkVersion 8构建工具版本21.1.2"默认配置{minSdk 版本 8目标SDK版本8}构建类型{释放 {minifyEnabled trueproguardFiles 'proguard.cfg'}}}

项目本身(即顶级)的整个 build.gradle 是:

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项.构建脚本{存储库{jcenter()}依赖{类路径 'com.android.tools.build:gradle:1.1.0'}}所有项目{存储库{jcenter()}}

我在这里找不到任何可以解释在调试版本上强制执行缩小的内容.

<小时>

更新 2: 怀疑应用程序的构建(debug)与其依赖的模块(release?)之间不匹配,我也检查左侧面板上的 Build Variant 视图.都明确显示debug.

<小时>

更新 3:我似乎遇到了Android-Gradle 中的错误/限制?

当应用在 debug 模式下构建时,我真的需要所有模块在 debug 模式下构建.

有什么想法可以解决这个问题吗?

解决方案

对于所有构建类型,minifyEnabled 的默认值是 false,正如@laalto 所回答的.>

然而,目前(截至 2015 年 4 月 24 日),对于多模块项目而言,情况并非如此,其中一些模块(包括应用程序)依赖在其他模块上.这是由于错误#52962导致构建类型不strong> 传播到库——它们总是作为 RELEASE 构建.

欢迎提出解决此错误的建议或对其修复的通知.

I imported several eclipse projects to Android Studio (v1.1).

In the original Eclipse environment, they use Proguard for release mode.

In the Android Studio environment, this was translated to the following in the build.gradle script (by the import, not by me):

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard.cfg'
    }
}

I understand that this means that "in release build, enable Proguard's minify, using proguard.cfg".

The problem, however, is that minify seems to be happening in non-release build (i.e. debug) as well!

How is this possible?

What is the default for minifyEnabled for debug build?


UPDATE 1: Thanks to the answer below, I now know that the default is false. Which means something else is building the various modules minified in debug build.

I am posting the entire build.gradle for one of the modules that get minified in debug build:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 8
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles 'proguard.cfg'
        }
    }
}

The entire build.gradle for the project itself (i.e. top level) is:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

I cannot spot here anything that could explain enforcing minify on a debug build.


UPDATE 2: Suspecting a mismatch between app's build (debug) and the modules on which it depends (release?), I also checked the Build Variant view on the the left panel. The all show debug unequivocally.


UPDATE 3: It appears that I hit a bug/limitation in Android-Gradle?

I truly need all modules built in debug mode when the app is built in debug mode.

Any ideas how I can solve this problem?

解决方案

The default value for minifyEnabled is false for all build types, as @laalto answered.

However, currently (as of 2015-04-24), this is not true for multi-module projects, in which some modules (app included) are dependent on other modules. This is due to bug #52962 that causes build types to not propagate to libraries -- they're always built as RELEASE.

Suggestions to work around this bug or notifications of its fix are most welcome.

这篇关于未明确编写脚本的 buildType 的 minifyEnabled 的默认值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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