android tutorial - Shrink the resources in android | Developer android - android app development - android studio - android app developement



Shrink the resources in android

To enable resource shrinking, set the shrinkResources property to true in your build.gradle file.

android {
    ...

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
click below button to copy code from our android learning website - android tutorial - team

Pay attention because resource shrinking works only in conjunction with code shrinking. You can customize which resources to keep or discard creating an XML file like this:

<?xml version=1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@layout/mylayout,@layout/custom_*"
    tools:discard="@layout/unused" />
click below button to copy code from our android learning website - android tutorial - team

Save this file in res/raw folder


Related Searches to Shrink the resources in android