Skip to content
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

Adding support for generating or passing UUID when uploading progurad mapping on .NET MAUI #3872

Open
rafalka opened this issue Jan 7, 2025 · 4 comments
Labels
Bug Something isn't working

Comments

@rafalka
Copy link

rafalka commented Jan 7, 2025

Problem Statement

Uploading a progurad file by <SentryUploadAndroidProguardMapping> but this file is not associated with any release

According https://docs.sentry.io/cli/dif/#uploading-files this association requires adding io.sentry.proguard-uuid meetadata to and using sentry-cli upload-proguard --uuid ...

Solution Brainstorm

Preferred solution: Generate UUID, inject it to AndroidManifest.xml and use during uploading
or: read this UUID from AndroidManifest.xml and use during uploading
or: add support for an environment variable

BTW: Shouldn't other switches --app-id my.app.id, --version. --version-code be used as well?

@bruno-garcia
Copy link
Member

Checks out, without uuid the there's no way for the mapping file and the app release to be associated.

Here's we add it to the gradle plugin:

https://github.com/getsentry/sentry-android-gradle-plugin/blob/3400d0b301a068815e73d240391043768a1c32ed/plugin-build/src/main/kotlin/io/sentry/android/gradle/tasks/SentryUploadProguardMappingsTask.kt#L67-L68

The app also needs to know what the uuid was, so it can attach it to events. The server needs to know what mapping file to look up.

like: https://github.com/getsentry/sentry-android-gradle-plugin/blob/3400d0b301a068815e73d240391043768a1c32ed/plugin-build/src/main/kotlin/io/sentry/android/gradle/tasks/SentryGenerateProguardUuidTask.kt#L54C19-L54C56

Ideally we use meta-data, like the docs you linked say:

<application>
  <meta-data
    android:name="io.sentry.proguard-uuid"
    android:value="A_VALID_UUID"
  />
</application>

@getsantry getsantry bot removed the status in GitHub Issues with 👀 3 Jan 7, 2025
@jamescrosswell jamescrosswell added the Bug Something isn't working label Jan 7, 2025
@rafalka
Copy link
Author

rafalka commented Jan 8, 2025

I managed to find a workaround until this bug will be fixed:

    <PropertyGroup  Condition="'$(Configuration)'=='Release'">
        <ProguardUuid>$([System.Guid]::NewGuid())</ProguardUuid>
    </PropertyGroup>
    <ItemGroup  Condition="'$(Configuration)'=='Release'">
        <AssemblyAttribute Include="Android.App.MetaData">
            <_Parameter1>"io.sentry.proguard-uuid", Value = "$(ProguardUuid)"</_Parameter1>
            <_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
        </AssemblyAttribute>
    </ItemGroup>

    <!-- Upload Android Proguard mapping file to Sentry after the build. -->
    <Target Name="CustomUploadAndroidProguardMappingFileToSentry" AfterTargets="UploadDebugInfoToSentry" DependsOnTargets="PrepareSentryCLI"
        Condition="'$(SentryCLI)' != '' And '$(AndroidProguardMappingFile)' != '' And '$(Configuration)'=='Release'">

        <Message Importance="High" Text="Preparing to upload Android Proguard mapping to Sentry for '$(MSBuildProjectName)': $(AndroidProguardMappingFile))" />

        <Exec Command="$(SentryCLIProGuardMappingUploadCommand) --uuid &quot;$(ProguardUuid)&quot; --app-id &quot;$(ApplicationId)&quot; --version &quot;$(ApplicationDisplayVersion)&quot; --version-code &quot;$(ApplicationVersion)&quot; $(AndroidProguardMappingFile)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
            <Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
        </Exec>
        <Warning Condition="'$(_SentryCLIExitCode)' != '0'" Text="Sentry CLI could not upload proguard mapping." />
    </Target>    
    

please note than I use separated platform project and these entries I added only to my Android projects.
For single project MAUI app some extra conditions may be required

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 8, 2025
@bruno-garcia
Copy link
Member

Thank you for sharing that! would you be willing to share that fix in a PR? We have a single file where we do the sentry cli commands. it just missed these its u figured out already.

@rafalka
Copy link
Author

rafalka commented Jan 8, 2025

Sure!
Feel free to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Status: No status
Status: No status
Development

No branches or pull requests

3 participants