Skip to content

[CoreCLR][Fast Deploy] App crashes after an incremental C# edit on device or emulator #12201

Description

@davidnguyen-tech

Summary

With .NET 11 Preview 6 CoreCLR Debug, a Fast Deploy build/install succeeds after a
comment-only C# edit, but the app crashes on its next launch on both physical devices
and Android emulators.

An app-defined Activity passed to Intent is resolved as java.lang.Object, causing
an ActivityNotFoundException. A clean deployment launches successfully, and
restoring the original source makes the app launch successfully again.

Reproduction

Environment:

  • SDK 11.0.100-preview.6.26359.118
  • Android workload 37.0.0-preview.6.59
  • Physical arm64 Android device or API 36.1 arm64 emulator

Fresh Android and MAUI builds with no runtime or packaging overrides evaluated to the
same CoreCLR Debug/Fast Deploy behavior used below.

Create a fresh app:

dotnet new android -n AndroidFastDeployRepro

Add a second Activity:

[Activity(Label = "Fast Deploy Result")]
public sealed class SecondActivity : Activity
{
}

Launch it from MainActivity.OnCreate:

StartActivity(new Intent(this, typeof(SecondActivity)));

Build and install:

dotnet build AndroidFastDeployRepro.csproj \
  -c Debug -f net11.0-android -t:Install \
  -p:RuntimeIdentifier=android-arm64 \
  -p:UseMonoRuntime=false \
  -p:EmbedAssembliesIntoApk=false \
  -p:AdbTarget="-s DEVICE_SERIAL" \
  /bl:{}
  1. Launch the clean deployment. It successfully opens SecondActivity.
  2. Append a comment to MainActivity.cs.
  3. Run the same build/install command.
  4. Launch again.

The incremental launch fails:

android.content.ActivityNotFoundException:
Unable to find explicit activity class
{<package-name>/java.lang.Object}

Restoring the original source and rebuilding makes the launch succeed again.

The same clean-pass / incremental-fail / restored-pass sequence reproduces on a
Samsung A16 and an API 36.1 arm64 Android emulator.

Initial analysis

  • The app assembly MVID changes after the comment-only edit.
  • _CreateApplicationSharedLibraries relinks libxamarin-app.so with the new typemap.
  • _BuildApkFastDev is skipped, so the installed APK retains the old
    libxamarin-app.so.
  • Fast Deploy reports success and copies only the updated app DLL/PDB to
    files/.__override__.
  • CoreCLR loads the new assembly but performs managed-to-Java lookup with the old
    MVID map.

The clean and incremental APK and libxamarin-app.so hashes are identical, while the
app assembly and typemap MVID differ.

The template repro surfaces as an ActivityNotFoundException. The same mismatch was
also observed in AzureUX as no Java peer type found, followed by SIGABRT from its
unhandled-exception path.

_BuildApkFastDevStaticInputs does not include @(_ApplicationSharedLibrary), even
though _BuildApkFastDev packages that item.

Adding @(_ApplicationSharedLibrary) to the target inputs fixes the failure by
rebuilding and reinstalling the APK whenever the typemap library changes. This keeps
EmbedAssembliesIntoApk=false, but is a correctness fix rather than an assembly-only
Fast Deploy solution.

Related context:

Metadata

Metadata

Labels

needs-triageIssues that need to be assigned.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions