Search code examples
androidproguard

Android Studio not generating Mapping folder under Build folder


I just wanted to try proguard,to see how much my apk size will get reduced after using it.i followed all the steps from android developer site as well.

but android studio not able to generate mapping folder, how will i know which code of my app is getting obfuscated.

add tried to change the path of default mapping folder by adding this rule to proguard file but didnt work. i am using android studio to generate signed-apk. -printmapping build/outputs/mapping/release/mapping.txt

 apply plugin: 'com.android.application' apply plugin:'com.google.gms.google-services'

android { compileSdkVersion 25 buildToolsVersion '25.0.2' useLibrary 'org.apache.http.legacy'

dexOptions {
     incremental true
     maxProcessCount 4
     javaMaxHeapSize "3g"
 }
 defaultConfig {
     applicationId "com.metronomic.materno"
     minSdkVersion 16
     targetSdkVersion 25
     multiDexEnabled true

     // Add the following two lines
     renderscriptTargetApi 18
     renderscriptSupportModeEnabled true
     ndk {
         abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
     }
 }
 lintOptions {
     abortOnError false
 }
 buildTypes {
     release {
         debuggable false>             minifyEnabled true
         proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                 'proguard-rules.pro'
     }
 }
 buildTypes {
     debug {
         debuggable true
     }
     release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), proguard-rules.txt'
     }
 }
 packagingOptions {
     exclude 'META-INF/DEPENDENCIES.txt'
     exclude 'META-INF/DEPENDENCIES'
     exclude 'META-INF/dependencies.txt'
     exclude 'META-INF/LICENSE.txt'
     exclude 'META-INF/LICENSE'
     exclude 'META-INF/license.txt'
     exclude 'META-INF/LGPL2.1'
     exclude 'META-INF/NOTICE.txt'
     exclude 'META-INF/NOTICE'
     exclude 'META-INF/notice.txt'
 }
 productFlavors {

 } }}

Solution

  • You have the 'buildTypes' block twice, and the last one (which is the one that gets used by Android Studio) specifies "minifyEnabled false".

    So none of your code is getting proguarded at all.

    You should not have 2 buildTypes blocks.