tezvyn:

Roles of minifyEnabled and shrinkResources and common pitfalls

Source: developer.android.comintermediate

Tests R8 code shrinking vs resource stripping and runtime risks. Outline: minifyEnabled shrinks code; shrinkResources removes unused assets and requires minifyEnabled; dynamic access like getIdentifier() crashes; keep resources with tools:keep or keep.xml.

Tests separation of R8 code shrinking from resource shrinking and awareness of runtime crashes. Outline: minifyEnabled enables R8 to strip unused code and obfuscate; shrinkResources removes unreferenced assets but requires minifyEnabled as it depends on code reachability analysis. Pitfall: dynamically accessed resources via getIdentifier() or reflection are stripped, causing ResourceNotFoundException. Mitigation: use tools:keep in XML or keep rules in res/raw/keep.xml.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Roles of minifyEnabled and shrinkResources and common pitfalls · Tezvyn