.Net Maui 应用程序从 apk 安装时崩溃,但与调试器配合良好

问题描述 投票:0回答:0

我正在尝试为我的 .Net Maui 应用程序生成 APK,以便通过从已签名的 APK 安装它来在本地设备上测试它。为了生成 APK,我遵循了这个tutorial。我正在将生成的 APK 文件移动到 Android 设备并安装该应用程序,但该应用程序无法运行并在初始屏幕上崩溃。应用程序在 visual studio 的调试模式下使用时运行良好。

我在我的 csproj 文件中添加了这个

<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>

我已经使用 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...'

我是 Android 开发的新手。

android xamarin xamarin.android maui
© www.soinside.com 2019 - 2024. All rights reserved.