Fix: release otp.zip poisons subsequent debug native deploys#42
Merged
Conversation
mix mob.deploy --native reported success while silently leaving stale BEAMs on-device. Root cause: mix mob.release --android wrote otp.zip to the shared src/main/assets/, which Gradle merges into every build variant. A prior release build left it there for the next debug build to inherit too, and MobBridge.kt's extractOtpIfNeeded() re-extracts it on every reinstall (keyed off PackageInfo.lastUpdateTime), silently overwriting freshly pushed dev BEAMs with the stale release snapshot. The zip now goes to the release-variant asset source set (src/release/assets/), which Gradle never merges into debug builds, so a release build can no longer poison a later debug deploy structurally. NativeBuild.remove_stale_release_otp_zip/1 also heals any existing checkout that still carries the old leftover file. Verified end-to-end on a physical Moto G Power (non-rooted, run-as push path): reproduced the staleness by restoring the old file, then confirmed a real mix mob.release --android + mix mob.deploy --native round-trip with this fix leaves fresh BEAM content on-device. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mix mob.deploy --nativereports success but can silently leave stale BEAMs on-device. Root cause:mix mob.release --androidwritesotp.zipinto the sharedsrc/main/assets/Gradle source set, which every build variant merges — including debug. A prior release build leaves this file behind, andMobBridge.kt'sextractOtpIfNeeded()re-extracts it on the next app launch after any reinstall (keyed offPackageInfo.lastUpdateTime), silently overwriting freshly-pushed dev BEAMs with the stale release snapshot.otp.zipnow goes to the release-variant asset source set (src/release/assets/), which Gradle never merges into debug builds — structurally impossible to recur, not a "remember to clean up" convention.MobDev.NativeBuild.remove_stale_release_otp_zip/1runs before every debugassembleDebug, deleting a leftoversrc/main/assets/otp.zipif present, so existing checkouts (built with older mob_dev versions) get healed automatically.How this was found
Traced on a real Sloppy Joe app deploy: every intermediate step (fresh BEAM staged, tar built correctly,
adb pushsucceeded,run-as tar xfreturned clean exit 0 with no stderr) checked out, yet the on-device file stayed stale. Confirmed the bundled debug APK'sassets/otp.zipitself contained the stale content (a snapshot from an earliermix mob.release --androidrun), and that removing it fixed the very next deploy. Restoring the file reproduced the bug exactly.Test plan
mix test— 2119/2119 passing (4 new tests coveringReleaseAndroid.otp_zip_path/0andNativeBuild.remove_stale_release_otp_zip/1)mix format --check-formattedcleanmix credo --strictclean (0 issues)run-aspush path): ran a realmix mob.release --androidwith this fix, confirmedotp.ziplands insrc/release/assets/(notsrc/main/assets/) and is still correctly bundled into the release AAB via Gradle's variant merging, then ranmix mob.deploy --nativeimmediately after (the exact poisoning scenario) and confirmed fresh BEAM content on-device afterward🤖 Generated with Claude Code