In a local release build of Masareef, my expense tracker, three brand icons on the Settings screen drew as empty tiles. A heart icon in the same card drew fine. Gradle said BUILD SUCCESSFUL, the tests passed, and nothing in logcat looked like an error.
Everything I checked first was correct: the PNGs, their checksums, the APK's resource table, the resource keep list, the JS asset registry and the render tree. About ten probes, all fine. The layer that was actually broken was one I hadn't thought about: the embedded expo-updates manifest.
How expo-updates finds images in a release build#
With expo-updates installed, a release build doesn't load images straight from the bundle's asset registry. At launch, DatabaseLauncher.kt builds a map from each asset to a file, and it builds that map from the update embedded in the APK:
private fun embeddedAssetFileMap(): MutableMap<AssetEntity, String> {
val embeddedManifest = EmbeddedManifestUtils.getEmbeddedUpdate(context, configuration)
val embeddedAssets = embeddedManifest?.assetEntityList ?: listOf()
logger.info("embeddedAssetFileMap: embeddedAssets count = ${embeddedAssets.count()}")
// ...one entry per asset listed in the manifest
}EmbeddedManifestUtils reads that list from a file in the APK's assets called app.manifest. If an image is in the APK but not in app.manifest, it has no entry in the map, so nothing resolves it and it draws blank. No crash, no red box.
That's what happened. app.manifest was a day old, so every image added since then was missing from it.
Why Gradle never rebuilt app.manifest#
A Gradle task called create<Variant>UpdatesResources writes app.manifest (for release builds, createReleaseUpdatesResources). In the expo-updates version I was on (58.0.17), the task declared only strings as inputs:
@get:Input abstract val projectRoot: Property<String>
@get:Input abstract val nodeExecutableAndArgs: ListProperty<String>
@get:Input abstract val debuggableVariant: Property<Boolean>
@get:Input abstract val entryFile: Property<String>
@get:OutputDirectory abstract val assetDir: DirectoryPropertyGradle decides whether a task is UP-TO-DATE by comparing its inputs and outputs. The project root path, the node command and the entry file name never change when you add an image, so on an incremental build Gradle skipped the task and reused the old output. The JS bundle was rebuilt with the new images, and the manifest that maps them to files wasn't.
One general rule came out of this: a Gradle task whose only inputs are strings is never rerun on an incremental build, whatever changes on disk. Treat its output as stale.
Why only local builds broke#
Ship builds were never affected. My release script runs expo prebuild --clean, which deletes android/ and every Gradle output with it, so the manifest is always regenerated. The bug only hit incremental builds: the ones you install on your own phone to check a change. That's also why it looked so strange, since the store build was fine.
The fix#
Make the task always run. In expo-updates 58.0.17 I did this with a patch. The expo-updates 58.0.23 I have installed now does the same thing upstream, in ExpoUpdatesPlugin.kt:
val createUpdatesResourcesTask = project.tasks.register(
"create${targetName}UpdatesResources", CreateUpdatesResourcesTask::class.java
) {
// ...
// The fingerprint depends on native files, patches, and config that are not inputs of this task.
it.outputs.upToDateWhen { false }
}If you're on an older expo-updates, either upgrade or apply the same one-line upToDateWhen { false } with patch-package or pnpm patch. If you can't do either, run a clean build before testing images.
Forcing the task to rerun led to a second problem on my machine: the build died with OutOfMemoryError: Metaspace. Prebuild rewrites gradle.properties, so I raised the limits in a config plugin, where prebuild can't overwrite them:
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1536mCatch it before the phone does#
I also added a build-time check. After the APK is built, read app.manifest out of it and fail if any icon the app uses is missing:
unzip -p app-release.apk assets/app.manifest > app.manifest.jsonThen search that text for the Android resource name of each image. React Native names a bundled image after its path: folders joined with _, lowercased, anything outside [a-z0-9_] dropped, so assets/icons/WhatsApp.png becomes assets_icons_whatsapp. Fail the build on any name the manifest doesn't mention. Run against the stale manifest, my check reported exactly the 12 missing icons.
Checklist when a release-build image draws blank#
- Check logcat for
embeddedAssetFileMaplines from expo-updates. They tell you the image lookup goes through the embedded manifest. - Pull
assets/app.manifestout of the APK and search it for the missing image. - If it's missing, the manifest is stale. Rebuild with
createReleaseUpdatesResourcesforced to run (upgrade expo-updates, or patchupToDateWhen { false }). - Check the app's own logs for the subsystem before bisecting the APK. I read the line that named the layer last, after ten probes that all came back fine.