3

Configuration

  • Mutlidex is enabled.
  • MinifyEnabled is true in release only.

Gradle buildscript:

buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath "com.android.tools.build:gradle:2.1.3"
    }
}

Android DSL configuration:

android {
    defaultConfig {
        multiDexEnabled true
    }

    signingConfigs {
        debug {

        }

        release {

        }
    }

    buildTypes {
        debug {
            versionNameSuffix ".debug"
        }

        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFile getDefaultProguardFile("proguard-android.txt")
            proguardFile "proguard-project.txt"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }

    dataBinding {
        enabled = true
    }
}

Output from gradlew assembleDebug:

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:prePackageMarkerForDebug
:app:transformClassesWithJarMergingForDebug
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:transformClassesWithMultidexlistForDebug
ProGuard, version 5.2.1
Reading program jar [/<>/build/intermediates/transforms/jarMerging/debug/jars/1/1f/combined.jar]
Reading library jar [/<>/build-tools/23.0.3/lib/shrinkedAndroid.jar]
Preparing output jar [/<>/build/intermediates/multi-dex/debug/componentClasses.jar]
  Copying resources from program jar [/<>/build/intermediates/transforms/jarMerging/debug/jars/1/1f/combined.jar]
:app:transformClassesWithDexForDebug
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug

BUILD SUCCESSFUL

Total time: 1 mins 0.285 secs

I have tried:

buildTypes {
    debug {
        debuggable true
        minifyEnabled false
    }

    release {
        debuggable false
        minifyEnabled true
    }
}

References:

Community
  • 1
  • 1
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185

2 Answers2

3

When using multidex to split up your classes into multiple dex files, the Android plugin will internally use ProGuard to determine which classes have to be kept in the main classes.dex.

This execution has nothing to do with your own rules or the minifyEnabled flag and can be safely ignored although the log output may be annoying. To suppress the log messages, you can add the following to your build.gradle:

tasks.whenTaskAdded { task ->
  if (task.name.startsWith("transformClassesWithMultidexlistFor")) {
    task.logging.level = LogLevel.ERROR
  }
}
T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
  • Thanks for the explanation and investigation. This does work. `level` (`setLevel`) is deprecated. What should we use now? – Jared Burrows Sep 02 '16 at 17:50
0

You need to specify minifyEnabled false in the debug build type. It is generally there by default when you create a new project. You seem to have removed it.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110