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?
minifyEnabled true. // Enables resource shrinking, which is performed by the. // Android Gradle plugin. shrinkResources true. // Includes the default ProGuard rules files that are packaged with.
A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.
Flavor Dimensions is a way to group flavors by a name. For now, we're using just a single group. Add the following line in your defaultConfig block: flavorDimensions "default" Now syncing the gradle would give you the following product flavors: Android Build Variants combine build types and product flavors.
Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With