'Drawable resource not found after minify enabled in android app

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

Me also facing same issue minifyEnabled true shrinkResources = true

fun updateImage(context: Context, imageName: String, imageView: ImageView) {
    if (imageView.tag?.equals(imageName.lowercase()) != true) {
        imageView.setImageDrawable(
            ContextCompat.getDrawable(
                context,
                context.resources.getIdentifier(
                    imageName.lowercase(),
                    "drawable",
                    context.packageName
                )
            )
        )
        imageView.tag =
            context.resources.getIdentifier(
                imageName.lowercase(),
                "drawable",
                context.packageName
            )
    }
}

How can we resolve this issue.?



Solution 1:[1]

Try to set shrinkResources as false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fobidlim