New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAUI app crashes on Android in debug mode and has errors in release mode #21525
Comments
Thanks for the feedback, but we'll need some info: Did you try with
Based on
seems like you have small repro/test project. Would you be so kind and publish it as a public repo or upload it here. Our gurus need to take a look into it. Thanks. |
I already tried with
I put here my project but it's only the new project created by visual studio without ayn change, if you need bin or obj folder I can try to upload them but they are too large for this file. |
Thanks for the feedback. Few things:
thanks |
|
I have slightly different errors, but AOT related.
No. You do NOT need to upload them. You did everything right. |
Thank you for helping me, I'll remain available to do any tests you need |
Try using |
I have the same errors I had in the first try, like this morning |
This is csproj I tested and is OK. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.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);net8.0-tizen</TargetFrameworks> -->
<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
<OutputType>Exe</OutputType>
<RootNamespace>TestNet8</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Display name -->
<ApplicationTitle>TestNet8</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.testnet8</ApplicationId>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.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>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
<AndroidPackageFormat>apk</AndroidPackageFormat>
<EnableLLVM>True</EnableLLVM>
<TrimMode>partial</TrimMode>
<!--
<TrimMode>copyused</TrimMode>
-->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
<EnableLLVM>True</EnableLLVM>
<TrimMode>partial</TrimMode>
<!--
<TrimMode>copyused</TrimMode>
-->
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<!--
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.14" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.14" />
-->
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVresion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVresion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>
</Project> |
I copied your csproj but I continue to have the same errors. Could it be a problem in my PC? |
Most likely. Something might be messed up. Do you have previews installed? please, for starters:
then we'll see |
I've never installed any previews, here are the information you requested
|
Can you upload binlog, please?
If you are not comfortable with CLI this could help: |
I get this with your command following the instructions in the link and this using the Project System Tools extension I just noticed that with your command I don't have any error
|
My bad. Sorry. That command did not build Release and thus not done any optimizations. Too much work in parallel and then I make mistakes. Run target will trigger everything:
Another tip - delete bin and obj folders before. |
Don't worry, here are the updated files, I deleted bin and obj folders as requested. |
Seems like installation issue on your box. While I go through the logs, can you please try:
If that does not help I usually would do uninstall then install...
You can get the with
and yes please report if that helped. |
I tried |
@moljac I tried to uninstall and then reinstall these workloads
but I can only change the ones installed by the SDK, the ones installed by VS give me this error message: After reinstalling all the SDK workloads the problem was not solved yet |
I've seen similar behavior with obfuscated assemblies, but I don't see anything in the binlog that would point to something which looks like obfuscated assembly. (I could be missing something). The piece of information to diagnose this is the exact method for which the exception happens. You can get it by running the trimmer under a debugger. The simplest way is:
Alternatively, you could use https://github.com/vitek-karas/illinkrepro which will package all of the input files for the trimmer into a directory (see the description in the repo). You can then zip it and send it to use to repro here - for this I would advice you use the VS Feedback tool since that will give you the option to share this file "privately with just MS" and then just share the link to the feedback item here. |
I managed to reach this point and I can confirm it failed the same exact way
but i don't know how to run a command under a managed debugger as you requested in the last point
Could you explain me how to do it? Meanwhile I'll try your last suggestion; the project is an empty maui app, do you think there might be privacy issues if I put my .zip here?
|
How to debug it with VS: Open the You can also set the Debugger Type to Run the app with F5 - it should stop on the exception. If it doesn't open exception settings (Debug-> Windows -> Exception Settings) and make sure the Common Language Runtime Exception checkmark is checked, not just semi-checked (uncheck and check it again). Run again - now it might stop on some more exception, so if it does and it's not the one you're looking for just F5 over it and keep on running until it hits the problem in question) |
@vitek-karas here's the exception where the debugger stopped.
|
@fuxuejun - can you please share the callstack or the @paro-ricc - that looks like a native debugger exception - can you please make sure that you set the debugger type to Managed? In either case, could you share the callstack (that should not contain any confidential data as it will be callstack in the illink tool alone). |
@vitek-karas |
repro.zip |
sorry, i found the real reason is nuget cache file was modified by other program, just clean the nuget cache folder, then restore the nuget, then it works ok. |
Thank you so much, now everything works perfectly, even with version 8.0.20 |
I build my app, then I find debug and relase mode crashed, I found some dlls in workload was also modified, must delete dotnet/packs folder, reinstall msi file to resolve it. |
Description
I am attempting to run the demo app created by Visual Studio when creating a new MAUI .NET 8 project on Android, but I am encountering problems in both debug and release mode. When I run the app in debug mode, it crashes at startup with no useful errors. When I try to compile the app in release mode, I get different errors. I have tried different physical devices and emulators with the same results and have already attempted to reinstall Visual Studio. Can someone suggest additional tests or solutions to help me understand and resolve this problem?
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.3 GA
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.101
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
When I try to run the app in debug it crashes at startup with no useful errors:
Instead when I try to compile it in release mode I receive these errors:
without any changes:
set PublishTrimmed as false:
set PublishTrimmed and RunAOTCompilation as false:
The text was updated successfully, but these errors were encountered: