Removing unused resources requires unused code shrinking to be turned on

You might want to refer to the Android Documentation to shrink your code and resources:

Shrink your code and resources

Like a comment already pointed out, resource shrinking only works when you have used the code shrinker. To enable shrinkResources in your build.gradle file you must have first set minifyEnabled to true


Resource shrinking works only in conjunction with code shrinking. After the code shrinker removes all unused code, the resource shrinker can identify which resources the app still uses. This is especially true when you add code libraries that include resources—you must remove unused library code so the library resources become unreferenced and, thus, removable by the resource shrinker

To enable resource shrinking, set the shrinkResources property to true in your build.gradle file (alongside minifyEnabled for code shrinking). For example:

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

reference


Maybe you set by mistake minifyEnabled = false and shrinkResources = true in your buildTypes.debug, so, maybe, it is a root of a problem, not your buildTypes.release