0

I want to reduce my app size. I saw some tutorials and understood that I have to use the following code in build.gradle(app) :

buildTypes {
    release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
}

I tried it but the app size didn't change until I added another code and it worked :

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

My question is why it should be use debug because it wasn't used in tutorials I saw.

I'm worried about slow app with this way.

Note : My Android Studio version is 3.5 and my gradle version is 7.0.4.

Nima Khalili
  • 360
  • 4
  • 20

1 Answers1

1

An Android Studio project default buildtype is debug, you can see it on "Build Variants" panel on left bottom corner of Android Studio. You can also change it to release

ruby6221
  • 228
  • 1
  • 7
  • You can also build the release version on command line with `./gradlew app:assembleRelease`, then you don't have to switch Build Variants in Android Studio when you go back to debugging you app. Also read [Shrink, obfuscate, and optimize your app](https://developer.android.com/studio/build/shrink-code) carefully, as you might have to add additional keep rules if you use reflection in your application. – sgjesse Mar 02 '22 at 13:08