I'm trying to generate APK for my .Net Maui app to test it on the local device by installing it from a signed APK. In order to generate APK I followed this tutorial. I'm moving APK File generated to Android device and installing the app but the app is not working and crashes on the splash screen. App was working well when it was used in debugging mode from visual studio.
I added this in my csproj file
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>AmuMAUI</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<EnableDefaultCssItems>false</EnableDefaultCssItems>
<!-- Display name -->
<ApplicationTitle>Amu</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.amumaui</ApplicationId>
<ApplicationIdGuid>55D14972-B250-4058-A1C2-41A290336F</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
<BuildIpa>True</BuildIpa>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-maccatalyst|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041.0|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
<BuildIpa>True</BuildIpa>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-maccatalyst|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-windows10.0.19041.0|AnyCPU'" />
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\Splash\amu_splash.svg" Color="#FFFFFF" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\amu_splash.svg" Color="#FFFFFF" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="Platforms\Android\Resources\xml\network_security_config.xml" />
<None Remove="Resources\Fonts\Bodoni-Bd-BT.TTF" />
<None Remove="Resources\Images\amuSplash.svg" />
</ItemGroup>
<ItemGroup>
<MauiFont Include="wwwroot\fonts\Bodoni-Bd-BT.ttf" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Blazorise" Version="1.1.5" />
<PackageReference Include="Blazorise.Bootstrap" Version="1.1.5" />
<PackageReference Include="Blazorise.Components" Version="1.1.5" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.5" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.5" />
<PackageReference Include="Blazorise.Sidebar" Version="1.1.5" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageReference Include="Plugin.LocalNotification" Version="10.1.4" />
<PackageReference Include="Radzen.Blazor" Version="4.4.7" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.0" />
<PackageReference Include="SQLitePCLRaw.provider.dynamic_cdecl" Version="2.1.0" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AmuEbUiShared\AmuUiShared.csproj" />
<ProjectReference Include="..\AmuEbViewModels\AmuEbViewModels.csproj" />
</ItemGroup>
<ItemGroup>
<MauiImage Include="Resources\Splash\amu_splash.svg" />
<MauiImage Include="wwwroot\images\amulogo.svg" />
</ItemGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidLinkResources>false</AndroidLinkResources>
<AndroidDexTool>r8</AndroidDexTool>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>amu.keystore</AndroidSigningKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>mypass</AndroidSigningKeyPass>
<AndroidSigningStorePass>mypass</AndroidSigningStorePass>
</PropertyGroup>
</Project>
I've checked logs using logcat
03-25 08:28:06.710 6419 6419 D ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
03-25 08:28:06.777 6419 6419 D CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10434; state: ENABLED
03-25 08:28:06.846 6419 6419 D nativeloader: Configuring classloader-namespace for other apk /system/framework/org.apache.http.legacy.jar. target_sdk_version=31, uses_libraries=ALL, library_path=/data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64:/data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.companyname.amumaui
03-25 08:28:06.846 6419 6419 D nativeloader: Extending system_exposed_libraries: libvraudio_client.qti.so:libbinauralrenderer_wrapper.qti.so:libhoaeffects.qti.so:libQOC.qti.so:libupdateprof.qti.so:libthermalclient.qti.so:libQOC.qti.so:libdiag_system.qti.so:libqape.qti.so:liblistenjni.qti.so
03-25 08:28:06.850 6419 6419 W ziparchive: Unable to open '/data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/base.dm': No such file or directory
03-25 08:28:06.850 6419 6419 W ziparchive: Unable to open '/data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/base.dm': No such file or directory
03-25 08:28:07.150 6419 6419 D nativeloader: Configuring classloader-namespace for other apk /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/base.apk. target_sdk_version=31, uses_libraries=, library_path=/data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64:/data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.companyname.amumaui
03-25 08:28:07.175 6419 6419 V GraphicsEnvironment: ANGLE Developer option for 'com.companyname.amumaui' set to: 'default'
03-25 08:28:07.175 6419 6419 V GraphicsEnvironment: Neither updatable production driver nor prerelease driver is supported.
03-25 08:28:07.179 6419 6419 D NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
03-25 08:28:07.181 6419 6419 D NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
03-25 08:28:07.188 6419 6419 D debug-app-helper: Checking if libmonodroid was unpacked to /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64/libmonodroid.so
03-25 08:28:07.188 6419 6419 D debug-app-helper: Native libs extracted to /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64, assuming application/android:extractNativeLibs == true
03-25 08:28:07.188 6419 6419 I debug-app-helper: Setting up for DSO lookup in app data directories
03-25 08:28:07.188 6419 6419 D debug-app-helper: Added filesystem DSO lookup location: /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64
03-25 08:28:07.188 6419 6419 W debug-app-helper: Using runtime path: /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64
03-25 08:28:07.188 6419 6419 W debug-app-helper: checking directory: `/data/user/0/com.companyname.amumaui/files/.__override__/lib`
03-25 08:28:07.188 6419 6419 W debug-app-helper: directory does not exist: `/data/user/0/com.companyname.amumaui/files/.__override__/lib`
03-25 08:28:07.188 6419 6419 W debug-app-helper: Checking whether Mono runtime exists at: /data/user/0/com.companyname.amumaui/files/.__override__/libmonosgen-2.0.so
03-25 08:28:07.188 6419 6419 W debug-app-helper: Checking whether Mono runtime exists at: /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64/libmonosgen-2.0.so
03-25 08:28:07.188 6419 6419 I debug-app-helper: Mono runtime found at: /data/app/~~-15s6o83Qaub3pCI5MhNrg==/com.companyname.amumaui-gwKbAsbO2ynCWaiorbb4Sw==/lib/arm64/libmonosgen-2.0.so
03-25 08:28:07.190 6419 6419 W yname.amumau: Attempt to remove non-JNI local reference, dumping thread
03-25 08:28:07.193 6419 6419 I DOTNET : JNI_OnLoad: JNI_OnLoad in pal_jni.c
03-25 08:28:07.202 6419 6419 W monodroid: Creating public update directory: `/data/user/0/com.companyname.amumaui/files/.__override__`
03-25 08:28:07.202 6419 6419 W yname.amumau: Attempt to remove non-JNI local reference, dumping thread
03-25 08:28:07.202 6419 6419 W monodroid: runtime args empty
03-25 08:28:07.205 6419 6419 F monodroid: No assemblies found in '/data/user/0/com.companyname.amumaui/files/.__override__' or '<unavailable>'. Assuming this is part of Fast Deployment. Exiting...
03-25 08:28:07.205 6419 6419 F monodroid: Make sure that all entries in the APK directory named `assemblies/` are STORED (not compressed)
03-25 08:28:07.205 6419 6419 F monodroid: If Android Gradle Plugin's minification feature is enabled, it is likely all the entries in `assemblies/` are compressed
03-25 08:28:07.206 6419 6419 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6419 (yname.amumaui), pid 6419 (yname.amumaui)
03-25 08:28:07.626 6450 6450 F DEBUG : Softversion: PD2034CF_EX_A_6.8.8
03-25 08:28:07.626 6450 6450 F DEBUG : Time: 2023-03-25 08:28:07
03-25 08:28:07.626 6450 6450 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-25 08:28:07.626 6450 6450 F DEBUG : Build fingerprint: 'vivo/789075/2027:12/SP1A.210812.003/compiler08021735:user/release-keys'
03-25 08:28:07.626 6450 6450 F DEBUG : Revision: '0'
03-25 08:28:07.626 6450 6450 F DEBUG : ABI: 'arm64'
03-25 08:28:07.626 6450 6450 F DEBUG : Timestamp: 2023-03-25 08:28:07.281564827+0500
03-25 08:28:07.626 6450 6450 F DEBUG : Process uptime: 0s
03-25 08:28:07.626 6450 6450 F DEBUG : Cmdline: com.companyname.amumaui
03-25 08:28:07.626 6450 6450 F DEBUG : pid: 6419, tid: 6419, name: yname.amumaui >>> com.companyname.amumaui <<<
03-25 08:28:07.626 6450 6450 F DEBUG : uid: 10434
03-25 08:28:07.626 6450 6450 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
03-25 08:28:07.626 6450 6450 F DEBUG : Abort message: 'No assemblies found in '/data/user/0/com.companyname.amumaui/files/.__override__' or '<unavailable>'. Assuming this is part of Fast Deployment. Exiting...'
I'm very new to Android development.
I had the same problem. Adding the following lines to the csproj file (as @h-a-h mentioned in the OP's comment) resolved the issue for me.
<PropertyGroup>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<RunAOTCompilation>False</RunAOTCompilation>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>