Android App Won't Launch when installed from APK

Geoff Knoll 5 Reputation points
2024-05-02T13:47:13.35+00:00

I am experiencing issues when trying to use our signed Android MAUI application running after I install it from an APK onto emulator or physical device.

It installs without issue, but when launched it freezes and crashes. Since our application is fairly complex I decided to see if I could reproduce with a simple sample, and I was able to.

Configuration:

  • Windows 11
  • VS 2022
  • Android emulator: Pixel_7_Pro _API_34 (Android 14.0 - API 34)
  • Latest MAUI packages (8.0.21)

Steps:

  1. Create new MAUI application (XAML).
  2. Upgrade NuGet packages once solution is created to latest MAUI builds.
  3. Build project.
  4. Run against emulator and verify it works. It does.
  5. Go to emulator uninstall application that was created.
  6. Now go to bin\Debug\net8.0-android folder, and somehow get the Signed.apk file onto the emulator. I used Google Drive as my emulator which is hooked to one of my Google accounts.
  7. Run the APK to install the application onto the emulator. Installs without issue.
  8. Navigate to home screen and select application to launch.
  9. It shows splash screen and then crashes without any error message. I was able to get a bug report generated from the emulator and can see where it crashes...but not seeing anything obvious as to what is causing it to crash. It seems similar to the issue reported here. https://github.com/dotnet/maui/issues/14378.
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,956 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Geoff Knoll 5 Reputation points
    2024-05-02T17:57:15.15+00:00

    After searching came across this post on Stack Overflow and adding the below to my project fixed my issue.

    https://stackoverflow.com/questions/75832206/net-maui-app-crashes-when-installed-from-apk-but-works-well-with-debugger

    <PropertyGroup Condition="'$(TargetFramework)'=='net8.0-android'"> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <RunAOTCompilation>False</RunAOTCompilation> <PublishTrimmed>False</PublishTrimmed> </PropertyGroup>

    1 person found this answer helpful.