Skip to content

Conversation

@alexsohn1126
Copy link
Member

fixes #3872

Problem

We were not automatically injecting uuid to the MAUI Android apk, so developers would have to manually go in and edit AndroidManifest.xml.

Solution

As proposed by @rafalka, we can inject the uuid to the Apk, and upload the proguard file with the same uuid.

Before

Before the fix, running in the MAUI project would upload the proguard file with the uuid, but it won't inject the uuid to the Android app.

After

We should now see the proguard file in Sentry with some uuid:

image

If we open the resulting APK in Android studio to inspect it's AndroidManifest.xml, we can see that it correctly set the meta-data field:

image

Testing method

To test this change using our samples/Sentry.Samples.Maui, we need to modify src/Sentry/buildTransitive/Sentry.targets file. If not using our sample MAUI project, ignore this step.

We have to remove the check whether this is a Sentry project or not. So delete the and [...] in line 72-73:

<UseSentryCLI Condition="
'$(UseSentryCLI)' == ''
and ('$(SentryUploadSymbols)' == 'true' or '$(SentryUploadSources)' == 'true' or $(SentryUploadAndroidProguardMapping) == 'true' or $(SentryCreateRelease) == 'true' or $(SentrySetCommits) == 'true')
and '$(MSBuildProjectName)' != 'Sentry'
and !$(MSBuildProjectName.StartsWith('Sentry.'))">true</UseSentryCLI>

Next, ensure SentryUploadAndroidProguardMapping is set to true in your MAUI project's .csproj file:

    <SentryUploadAndroidProguardMapping>true</SentryUploadAndroidProguardMapping>

In the same file, enable Proguard. This is what I used:

  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <AndroidLinkTool>r8</AndroidLinkTool>
    <AndroidLinkMode>Full</AndroidLinkMode>
    <AndroidEnableProguard>true</AndroidEnableProguard>
  </PropertyGroup>

Run dotnet publish -f net9.0-android35.0 -c Release in the MAUI project root.

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.36%. Comparing base (58b5da0) to head (30e19d4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4532      +/-   ##
==========================================
- Coverage   73.37%   73.36%   -0.02%     
==========================================
  Files         479      479              
  Lines       17505    17505              
  Branches     3445     3445              
==========================================
- Hits        12844    12842       -2     
- Misses       3783     3784       +1     
- Partials      878      879       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexsohn1126
Copy link
Member Author

alexsohn1126 commented Sep 17, 2025

Looks like there is an endpoint for proguard artifact upload that is not implemented in sentry-cli integration tests server.

In other integration test servers, they have endpoints for proguard-artifact-releases:

I'll make a PR over at sentry-cli tomorrow for this, or should I ask someone else?

Doesn't seem too hard to make it, what can possibly go wrong 🫨

@alexsohn1126
Copy link
Member Author

Actually, it's kind of weird that we are getting errors from uploading proguards now but we weren't before?

Maybe something's up with my implementation, but from what I can see, it doesn't touch the condition which the proguard file is sent so...

@alexsohn1126
Copy link
Member Author

Blocked by getsentry/github-workflow #100

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks @alexsohn1126 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding support for generating or passing UUID when uploading proguard mapping on .NET MAUI

7 participants