.Net MAUI发布部署崩溃,但调试部署正常。

huangapple go评论139阅读模式
英文:

.Net MAUI release deployment crashes but debug deployment works

问题

当我将我的应用程序发布到一个APK文件并安装到Android设备上时,该应用程序总是崩溃。当我将软件的调试版本部署到同一设备时,情况并非如此。在这两种情况下,项目构建没有错误。我收到以下异常:

android.runtime.JavaProxyThrowable: System.IO.FileNotFoundException: /MyApp.dll

无论是在实际设备还是模拟器上都会发生这种情况。无论是从Visual Studio直接进行发布和签名部署,还是使用CLI发布并手动安装APK,都会发生这种情况。

我在Visual Studio 2022中使用.NET 7.0进行开发,Android设备运行在API 33上。

发布并签名应用程序到APK文件,然后手动将签名的APK安装到设备上。

期望:

  • 成功构建签名的APK。
  • 在设备上手动安装APK。
  • 应用程序运行正常。

实际情况:

  • 成功构建签名的APK。
  • 在设备上手动安装APK。
  • 应用程序在启动时崩溃,出现上述异常。
英文:

When I publish my application to an APK file and install it to an android device the app will always crash. This is not the case when I deploy a debug version of the software to the same device. In both cases, the project builds without errors. I get the following exception:

android.runtime.JavaProxyThrowable: System.IO.FileNotFoundException: /MyApp.dll

This happens regardless of device or emulator. This also happens regardless of a release deployment directly from visual studio or using the CLI publish with a manual install of the APK.

I am working in Visual Studio 2022 with .net 7.0 and the android device is on API 33.

Publish and sign the application to an APK file. Then manually install the signed APK on device.

Expected:
Successful build of signed APK.
Manual install of APK on device.
Application runs without issues.

Actual:
Successful build of signed APK.
Manual install of APK on device.
Application crashes on app start with the exception stated.

答案1

得分: 0

我之前使用FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion来在我的一个页面上显示文件版本。但是这对于发布版本来说不起作用,因为它不知道要查找哪个地方。

英文:

I was using FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion to display the file version on one of my pages. However this does not work for the release version since it doesn't know where to look.

答案2

得分: 0

尝试取消勾选AOT编译
这帮助我解决了问题

.Net MAUI发布部署崩溃,但调试部署正常。

英文:

Try uncheck AOT compilation
This helped me solve the problem

.Net MAUI发布部署崩溃,但调试部署正常。

huangapple
  • 本文由 发表于 2023年3月10日 00:29:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687445.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定