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.
What is the default for minifyEnabled for debug build?
The default value for minifyEnabled
is false
for all build types. Reference.
The problem, however, is that minify seems to be happening in non-release build (i.e. debug) as well!
How is this possible?
Your debug build gets proguard treatment possibly by some other definition somewhere, or an external build script you're using.
In your updated question, you have a library project and an app project that uses a minified library even for debug builds. That's a "feature". For a solution, consider the following also mentioned in the issue report:
Build all variants of the library project by adding the following to its build.gradle
:
android {
publishNonDefault true
}
In the app project, choose the build type specific dependency with
dependencies {
releaseCompile project(path: ':theotherproject', configuration: 'release')
debugCompile project(path: ':theotherproject', configuration: 'debug')
}
来源:https://stackoverflow.com/questions/29846750/what-is-the-default-for-minifyenabled-for-buildtype-not-explicitly-scripted