Skip to content

[Xamarin.Android.Build.Tasks] Remove dead InstantRun leftovers#11656

Open
jonathanpeppers wants to merge 2 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers/remove-instantrun-leftovers
Open

[Xamarin.Android.Build.Tasks] Remove dead InstantRun leftovers#11656
jonathanpeppers wants to merge 2 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers/remove-instantrun-leftovers

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

"Enhanced Fast Deployment" / Instant Run support was removed in #9292 (MSBuild plumbing) and #9297 (native runtime side). #9292''s description left a TODO: "In a future PR, we could consider making runtime changes to remove instant_run_enabled as well." This is that future PR — it deletes the corresponding Java types and the AndroidManifest.xml hook that instantiated them.

What was actually still doing anything?

Nothing useful. After #9297 deleted the native side, the Bazel-derived Java types in src-ThirdParty/bazel/java/mono/android/... became unreachable runtime no-ops:

  • release/MultiDexLoader.java''s getDexList() always returned an empty List<String>, so IncrementalClassLoader.inject() was never called.
  • debug/MultiDexLoader.java scanned $filesDir/.__override__/dexes/ for hot-pushed .dex files. Nothing in the build pipeline ever populates that directory anymore — FastDeploy.cs and the native runtime use .__override__/ for managed .dlls and .__override__/$abi/ for .sos, never .dex.
  • incrementaldeployment/IncrementalClassLoader.java was only reachable through the dead inject() call above.
  • src/java-runtime/java/mono/android/incrementaldeployment/Placeholder.java was the matching "tiny main dex" Bazel-style placeholder.

The only consumer of the Java side was ManifestDocument.MergeManifest(), which injected a mono.android.MultiDexLoader ContentProvider when $(AndroidEnableMultiDex) was true. No test asserted the provider''s presence, and its attachInfo() body was effectively a no-op.

What this PR does

  • Deletes the three src-ThirdParty/bazel/java/... files and Placeholder.java.
  • Removes the bazelbuild/bazel entry from THIRD-PARTY-NOTICES.TXT and the update-tpn skill, since no vendored Bazel sources remain.
  • Drops the <src-ThirdParty\bazel\...> glob and now-stale RemoveItems entries from src/java-runtime/java-runtime.{csproj,targets}.
  • Removes ManifestDocument.MultiDex, the mono.android.MultiDexLoader provider injection, and the corresponding MultiDex task parameter on GenerateMainAndroidManifest (plus its callsite in Microsoft.Android.Sdk.TypeMap.LlvmIr.targets).

What is unaffected

$(AndroidEnableMultiDex) itself. The real multidex feature still works via android.support.multidex.MultiDexApplication and D8/R8 producing classes.dex + classes2.dex. Existing tests BuildMultiDexApplication, BuildAfterMultiDexIsNotRequired, CustomApplicationClassAndMultiDex, and MultiDexAndCodeShrinker cover that path and don''t reference any of the removed types.

Context: dotnet#9292
Context: dotnet#9297

When "Enhanced Fast Deployment" / Instant Run was removed in dotnet#9292
(MSBuild plumbing) and dotnet#9297 (native runtime), the corresponding Java
support and the manifest-side hook were left behind. This commit
finishes the cleanup that dotnet#9292 said was for "a future PR":

* Delete `src-ThirdParty/bazel/java/mono/android/{debug,release}/MultiDexLoader.java`
  and `incrementaldeployment/IncrementalClassLoader.java`. These were
  introduced in dotnet#609 to spice fast-deployed `.dex` files into the app
  classloader at startup. With the native side gone, the release variant's
  `getDexList()` always returned an empty list (so `IncrementalClassLoader.inject()`
  was never called) and the debug variant scanned an `__override__/dexes/`
  directory that nothing in the build pipeline ever populates.

* Delete `src/java-runtime/java/mono/android/incrementaldeployment/Placeholder.java`,
  the corresponding "tiny main dex" Bazel-style placeholder.

* Drop the `<src-ThirdParty/bazel/...>` glob and the now-stale
  `RemoveItems` entries from `src/java-runtime/java-runtime.{csproj,targets}`.

* Drop `ManifestDocument.MultiDex` and the `mono.android.MultiDexLoader`
  ContentProvider injection in `MergeManifest()`. Nothing else referenced
  the class name, and no test asserted the provider's presence.

* Drop the corresponding `MultiDex` parameter from `GenerateMainAndroidManifest`
  and its callsite in `Microsoft.Android.Sdk.TypeMap.LlvmIr.targets`.

* Remove the `bazelbuild/bazel` entry from `THIRD-PARTY-NOTICES.TXT`
  and the `update-tpn` skill, since the only vendored Bazel sources have
  been deleted.

The `$(AndroidEnableMultiDex)` feature itself is unaffected. It still
works via `android.support.multidex.MultiDexApplication` and D8/R8
producing `classes.dex` + `classes2.dex`; existing tests
(`BuildMultiDexApplication`, `BuildAfterMultiDexIsNotRequired`,
`MultiDexAndCodeShrinker`, etc.) cover that path and don't depend on
the removed types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 15, 2026 17:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the remaining unreachable “Enhanced Fast Deployment” / Instant Run Java + manifest plumbing from the build tasks and Java runtime packaging, following the prior removal of the MSBuild and native runtime support. This simplifies the codebase and eliminates stale third-party Bazel remnants.

Changes:

  • Removed the mono.android.MultiDexLoader ContentProvider injection (and the associated MultiDex task/manifest plumbing) which was only tied to dead Instant Run behavior.
  • Deleted the Bazel-derived Java sources (MultiDexLoader, IncrementalClassLoader) and the matching runtime placeholder type, and stopped including src-ThirdParty/bazel sources in java-runtime.
  • Updated third-party notices and the update-tpn skill documentation to reflect the removal of vendored Bazel sources.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
THIRD-PARTY-NOTICES.TXT Removes the Bazel entry and its license block since Bazel sources are no longer vendored.
src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs Drops MultiDex property and removes provider injection of mono.android.MultiDexLoader.
src/Xamarin.Android.Build.Tasks/Tasks/GenerateMainAndroidManifest.cs Removes the MultiDex MSBuild task parameter and stops passing it into manifest merging.
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets Stops passing MultiDex="$(AndroidEnableMultiDex)" to GenerateMainAndroidManifest.
src/java-runtime/java/mono/android/incrementaldeployment/Placeholder.java Deletes unused Instant Run placeholder Java type.
src/java-runtime/java-runtime.targets Removes now-stale RemoveItems entries that referenced deleted Bazel Java sources.
src/java-runtime/java-runtime.csproj Stops glob-including src-ThirdParty/bazel/java/**/*.java into the Java runtime build inputs.
src-ThirdParty/bazel/java/mono/android/release/MultiDexLoader.java Deletes unused Bazel-derived MultiDexLoader implementation.
src-ThirdParty/bazel/java/mono/android/incrementaldeployment/IncrementalClassLoader.java Deletes unused Bazel-derived incremental classloader.
src-ThirdParty/bazel/java/mono/android/debug/MultiDexLoader.java Deletes unused Bazel-derived debug MultiDexLoader implementation.
.github/skills/update-tpn/SKILL.md Removes the Bazel row from the “vendored source” table since src-ThirdParty/bazel is gone.

The BuildReleaseArm64 apkdiff regression tests fail because removing the
mono.android.incrementaldeployment Java sources shrinks classes.dex by
more than the 5% threshold:

- BuildReleaseArm64(False,MonoVM)      classes.dex 22384 -> 19036
- BuildReleaseArm64(False,NativeAOT)   classes.dex 25400 -> 22016
- BuildReleaseArm64(True,CoreCLR)      classes2.dex 156448 -> 108080

Refresh the reference .apkdesc files using the descriptions saved by
apkdiff during the failing CI runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants