dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.89k stars 525 forks source link

Support for Play Store "Native Crash Support" #8903

Open hansmbakker opened 2 months ago

hansmbakker commented 2 months ago

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

.NET MAUI 8.0

Description

I'm uploading app bundles, which were built using Release mode, to the Play Store.

On the Play Store developer console I'm getting the warning

This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug.

It links to https://developer.android.com/build/shrink-code#native-crash-support for more details.

I cannot find any mention of it on https://learn.microsoft.com/en-us/dotnet/maui/android/deployment/publish-google-play?view=net-maui-8.0, and when looking online for ways to fix this, I only found forum discussions without a solution like https://learn.microsoft.com/en-us/answers/questions/238871/this-app-bundle-contains-native-code.

I couldn't find a GitHub issue tracking this, and was wondering what I could do to fix this (the forum post was from 2021 - it is 2024 now, is there a new recommendation?).

Steps to Reproduce

  1. Build an app in release mode
  2. Upload it to the Play Store

Did you find any workaround?

No response

Relevant log output

No response

hansmbakker commented 2 months ago

This stackoverflow post asks the same question.

hansmbakker commented 2 months ago

~https://github.com/xamarin/xamarin-android/pull/5304 suggests that a mappings.txt should exist in the generated AAB file, but when I look in the AAB generated on Azure DevOps, I couldn't find it.~

I found out that mappings.txt is created when AndroidCreateProguardMappingFile is enabled, optionally when by setting AndroidLinkTool to r8.

However, this does not result in a file with debug symbols, as the warning asks for.

https://github.com/xamarin/xamarin-android/issues/5378 specifically asks for these symbol files, and then the conversation moves towards mappings.txt.

There is something mentioned around breakpad at https://learn.microsoft.com/en-us/appcenter/diagnostics/unmanaged-code-crash-support (this page will likely be removed next year with the discontinuation of AppCenter), and is not incorporated in the MAUI or .NET for Android documentation. It is not clear if breakpad is needed for Android applications and it is not clear how to set it up in Visual Studio.

Googles documentation about Deobfuscate or symbolicate crash stack traces suggests that for Java code, a deobfuscation mappings file might be sufficient, and that for native code, debug symbols are needed. What I don't understand is how .NET for Android code can be classified after it has undergone the optimization step.

@jonathanpeppers it is not clear to me whether separate debug symbol files are needed after the mappings.txt files are uploaded. Are they needed to get clean stacktraces, and if so, what can I do to generate the debug symbols?