Development and production can retain different data
On September 24, 2026, we changed how the license screen loads its library-list data to address a crash. Instead of asking AboutLibraries to discover the data, we pass the resource ID of the bundled JSON directly. The change affected the import and loading call.
Production resource shrinking removes unused images and data. Data available during development does not necessarily remain under production build conditions.
Identify known data directly
Dynamic name-based discovery can obscure usage at build time. We switched AboutLibraries loading to pass the resource ID of the list data. This example shows that loading step.
Libs.Builder()
.withJson(context, R.raw.aboutlibraries)
.build()
An explicit reference keeps the dependency visible without disabling shrinking throughout the app. This does not mean every dynamic resource is removed; it communicates use of known data where it is consumed.
Distinguish missing code from missing data
Code shrinking removes classes and other code, while resource shrinking removes bundled data. A retention rule for reflection-loaded classes does not necessarily fix a data-reference problem.
Code from the Fix
The following excerpts illustrate the fix; some examples omit surrounding code.
val libraries by produceLibraries { ctx ->
Libs.Builder()
.withJson(ctx, R.raw.aboutlibraries)
.build()
}
Inspect artifacts under the conditions you ship
Open the affected screen in a production build with shrinking enabled and examine whether required data is included in the artifact. Development builds alone can miss removal conditions.
The same reasoning applies to images, configuration files, and templates. Making dependencies visible to build tools as well as people helps investigate failures introduced by production optimization.
No comments:
Post a Comment