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

Sentry mapping file upload task is missing from version 4.3.0 #713

Open
ZeeshanShabbir opened this issue May 21, 2024 · 19 comments
Open

Sentry mapping file upload task is missing from version 4.3.0 #713

ZeeshanShabbir opened this issue May 21, 2024 · 19 comments
Assignees
Labels
bug Something isn't working Platform: Android Sync: Jira apply to auto-create a Jira shadow ticket

Comments

@ZeeshanShabbir
Copy link

ZeeshanShabbir commented May 21, 2024

Gradle Version

8.7

AGP Version

8.4.0

Code Minifier/Optimizer

Dexguard

Version

4.6.0

Sentry SDK Version

7.9.0

Steps to Reproduce

We are using https://github.com/Triple-T/gradle-play-publisher to generate and upload our app bundles to the distribution channel. We recently noticed that the sentry mapping file is missing on further investigation we found out that issue started to happen after we updated to 4.4.0 and 4.6.0 also have this issue.

After enabling debug for sentry configuration we see following logs.

DEBUG: UncaughtExceptionHandlerIntegration removed.
INFO: Closing SentryClient.
DEBUG: Serializing object: {"transaction":"gradle build Android","start_timestamp":1716308381.189080,"timestamp":1716310318.748254,"spans":[{"start_timestamp":1716308433.217697,"timestamp":1716308433.226593,"trace_id":"0f5a8210c6414747bacffe1a55546e57","span_id":"99ecb1cae33b4d0b","parent_span_id":"fe3c305b2ff64857","op":"3379458255_SentryGenerateIntegrationListTask_Decorated","origin":"manual","data":{}},{"start_timestamp":1716308585.934229,"timestamp":1716308585.934844,"trace_id":"0f5a8210c6414747bacffe1a55546e57","span_id":"2a8f226dc04047ca","parent_span_id":"fe3c305b2ff64857","op":"3379458255_SentryExternalDependenciesReportTaskV2_Decorated","origin":"manual","data":{}},{"start_timestamp":1716308623.873808,"timestamp":1716308623.875345,"trace_id":"0f5a8210c6414747bacffe1a55546e57","span_id":"9d28800a82044295","parent_span_id":"fe3c305b2ff64857","op":"3379458255_SentryGenerateProguardUuidTask_Decorated","origin":"manual","data":{}},{"start_timestamp":1716308624.150534,"timestamp":1716308624.152972,"trace_id":"0f5a8210c6414747bacffe1a55546e57","span_id":"ac2bafe159e249b3","parent_span_id":"fe3c305b2ff64857","op":"3379458255_InjectSentryMetaPropertiesIntoAssetsTask_Decorated","origin":"manual","data":{}}],"type":"transaction","transaction_info":{"source":"custom"},"event_id":"bbff1d0034e34bfc8af0cc0f29b46f10","contexts":{"runtime":{"name":"Private Build","version":"17.0.10"},"trace":{"trace_id":"0f5a8210c6414747bacffe1a55546e57","span_id":"fe3c305b2ff64857","op":"build","origin":"manual"}},"sdk":{"name":"sentry.java","version":"6.31.0","packages":[{"name":"maven:io.sentry:sentry","version":"6.31.0"}],"integrations":["UncaughtExceptionHandler","ShutdownHook"]},"tags":{"AGP_VERSION":"8.4.0","includeNativeSources":"false","ignoredBuildTypes_set":"true","tracing_enabled":"true","includeSourceContext":"false","autoInstallation_enabled":"true","uploadNativeSymbols":"false","autoUpload":"true","includeDependenciesReport":"true","SDK_VERSION":"7.9.0","dexguardEnabled":"true","tracing_features":"[FILE_IO, OKHTTP, COMPOSE]","tracing_logcat_minLevel":"WARNING","tracing_debug":"false","tracing_forceInstrumentDependencies":"false","SENTRY_CLI_VERSION":"2.31.2","ignoredVariants_set":"false","debug":"true","GRADLE_VERSION":"8.7","includeProguardMapping":"true","additionalSourceDirsForSourceContext_set":"false","BUILD_SYSTEM":"gradle","tracing_logcat_enabled":"true","autoInstallation_sentryVersion":"7.9.0","autoUploadNativeSymbols":"true","autoUploadProguardMapping":"true","ignoredFlavors_set":"false","step":"3379458255_InjectSentryMetaPropertiesIntoAssetsTask_Decorated"},"release":"4.6.0","environment":"Android","platform":"java","user":{"id":"delivery-hero-pm"},"server_name":"prd-linux-use5b-7c56872f-8634-4964-9848-b27a95f4fd03.c.bitrise-workers.internal"}
DEBUG: Envelope sent successfully.
DEBUG: Envelope flushed
DEBUG: Serializing object: {"sid":"014684e5-6d34-4eff-8b1c-6e2ff4c81b19","started":"2024-05-21T16:19:41.188Z","status":"exited","seq":1716310318748,"errors":0,"duration":1937.56,"timestamp":"2024-05-21T16:51:58.748Z","attrs":{"release":"4.6.0","environment":"Android"}}
DEBUG: Envelope sent successfully.
DEBUG: Envelope flushed
DEBUG: Shutting down

Expected Result

The mapping file should be uploaded to sentry

Actual Result

The mapping file upload task is missing hence, the mapping file is not uploaded to sentryThe mapping

┆Issue is synchronized with this Jira Improvement by Unito

@ZeeshanShabbir ZeeshanShabbir added bug Something isn't working Platform: Android labels May 21, 2024
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 21, 2024
@Angelodaniel Angelodaniel added the Sync: Jira apply to auto-create a Jira shadow ticket label May 22, 2024
@romtsn
Copy link
Member

romtsn commented May 22, 2024

hi @ZeeshanShabbir, thanks for the report! Presumably you're using DexGuard, right? I think the issue is most likely a consequence of this PR.

We'll probably need a bit more logs from you, e.g. what tasks have run in the build. You could also send them internally via your assigned solutions engineer, or directly to me at roman@sentry.io.

Thank you!

@stefanosiano stefanosiano moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK May 22, 2024
@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 May 22, 2024
@Angelodaniel
Copy link
Member

Hey @stefanosiano & @romtsn - I've added comments to the internal Jira ticket

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 May 27, 2024
@kahest kahest moved this from Needs More Information to Needs Discussion in Mobile & Cross Platform SDK May 29, 2024
@kahest
Copy link
Member

kahest commented May 29, 2024

@Angelodaniel thanks, we'll discuss in our sync today

@markushi markushi self-assigned this May 29, 2024
@markushi markushi moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK May 29, 2024
@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 May 29, 2024
@markushi markushi moved this from Needs More Information to Needs Investigation in Mobile & Cross Platform SDK May 29, 2024
@romtsn
Copy link
Member

romtsn commented Jun 3, 2024

a similar problem was reported over Discord: https://discord.com/channels/621778831602221064/1245430650635288729/1245430650635288729

seems like when the play-publisher-plugin task is executed (e.g. publish${Variant}Bundle), we only execute generateSentryProguardUuid but not the upload task

@github-project-automation github-project-automation bot moved this from In Progress to Done in Mobile & Cross Platform SDK Jun 19, 2024
@ZeeshanShabbir
Copy link
Author

ZeeshanShabbir commented Jul 8, 2024

We are still facing this issue that sentry mapping files aren’t uploaded still. We are using sentry android 7.11.0 and plugin version is 4.9.0. We are using the 3.10.1 version of Gradle Publisher Plugin

DEBUG: UncaughtExceptionHandlerIntegration removed.
INFO: Closing SentryClient.
DEBUG: Serializing object: {"transaction":"gradle build Android","start_timestamp":[REDACTED]720440084.2[REDACTED]3[REDACTED]64,"timestamp":[REDACTED]720442099.9776[REDACTED]4,"spans":[{"start_timestamp":[REDACTED]720440372.9893[REDACTED]2,"timestamp":[REDACTED]720440373.06[REDACTED]558,"trace_id":"0[REDACTED]fea[REDACTED]79a58e488587b55fa79aa2775b","span_id":"3a826a[REDACTED]bc9994[REDACTED]2f","parent_span_id":"f079dc0a[REDACTED]9cb40cd","op":"3379458255_SentryGenerateIntegrationListTask_Decorated","origin":"manual","data":{"thread.name":"Execution worker Thread 2","thread.id":"529"}},{"start_timestamp":[REDACTED]72044042[REDACTED].768049,"timestamp":[REDACTED]72044042[REDACTED].768660,"trace_id":"0[REDACTED]fea[REDACTED]79a58e488587b55fa79aa2775b","span_id":"8988d4bd86b34c99","parent_span_id":"f079dc0a[REDACTED]9cb40cd","op":"3379458255_SentryExternalDependenciesReportTaskV2_Decorated","origin":"manual","data":{"thread.name":"Execution worker Thread 5","thread.id":"532"}},{"start_timestamp":[REDACTED]720440480.774309,"timestamp":[REDACTED]720440480.775428,"trace_id":"0[REDACTED]fea[REDACTED]79a58e488587b55fa79aa2775b","span_id":"a77d[REDACTED]295cf04c3c","parent_span_id":"f079dc0a[REDACTED]9cb40cd","op":"3379458255_SentryGenerateProguardUuidTask_Decorated","origin":"manual","data":{"thread.name":"included builds","thread.id":"527"}},{"start_timestamp":[REDACTED]720440480.777584,"timestamp":[REDACTED]720440480.78[REDACTED]698,"trace_id":"0[REDACTED]fea[REDACTED]79a58e488587b55fa79aa2775b","span_id":"978682[REDACTED]fdafa492b","parent_span_id":"f079dc0a[REDACTED]9cb40cd","op":"3379458255_InjectSentryMetaPropertiesIntoAssetsTask_Decorated","origin":"manual","data":{"thread.name":"included builds","thread.id":"527"}}],"type":"transaction","transaction_info":{"source":"custom"},"event_id":"67539f0b0ec44e8f9724967[REDACTED]f2ac5d89","contexts":{"runtime":{"name":"Private Build","version":"2[REDACTED].0.2"},"trace":{"trace_id":"0[REDACTED]fea[REDACTED]79a58e488587b55fa79aa2775b","span_id":"f079dc0a[REDACTED]9cb40cd","op":"build","origin":"manual"}},"sdk":{"name":"sentry.java","version":"7.0.0","packages":[{"name":"maven:io.sentry:sentry","version":"7.0.0"}],"integrations":["UncaughtExceptionHandler","ShutdownHook"]},"tags":{"AGP_VERSION":"8.5.0","includeNativeSources":"false","ignoredBuildTypes_set":"true","tracing_enabled":"true","includeSourceContext":"false","autoInstallation_enabled":"true","uploadNativeSymbols":"false","autoUpload":"true","includeDependenciesReport":"true","SDK_VERSION":"7.[REDACTED].0","dexguardEnabled":"true","tracing_features":"[FILE_IO, OKHTTP, COMPOSE]","tracing_logcat_minLevel":"WARNING","tracing_debug":"false","tracing_forceInstrumentDependencies":"false","SENTRY_CLI_VERSION":"2.32.[REDACTED]","ignoredVariants_set":"false","debug":"true","GRADLE_VERSION":"8.8","includeProguardMapping":"true","additionalSourceDirsForSourceContext_set":"false","BUILD_SYSTEM":"gradle","tracing_logcat_enabled":"true","autoInstallation_sentryVersion":"7.[REDACTED].0","autoUploadNativeSymbols":"true","autoUploadProguardMapping":"true","ignoredFlavors_set":"false","step":"3379458255_InjectSentryMetaPropertiesIntoAssetsTask_Decorated"},"release":"4.9.0","environment":"Android","platform":"java","user":{"id":"delivery-hero-pm","ip_address":"{{auto}}"},"server_name":"prd-linux-use5a-6[REDACTED]7[REDACTED]a0e9-070[REDACTED]-42ff-84c9-4b96484[REDACTED]eba[REDACTED].c.bitrise-workers.internal"}
DEBUG: Envelope sent successfully.
DEBUG: Envelope flushed
DEBUG: Serializing object: {"sid":"ecbe7493-8732-4f28-b554-3d0300aa3f80","started":"2024-07-08T[REDACTED]2:0[REDACTED]:24.2[REDACTED]2Z","status":"exited","seq":[REDACTED]720442[REDACTED]00002,"errors":0,"duration":20[REDACTED]5.79,"timestamp":"2024-07-08T[REDACTED]2:35:00.002Z","attrs":{"release":"4.9.0","environment":"Android"}}
DEBUG: Envelope sent successfully.
DEBUG: Envelope flushed
DEBUG: Shutting down

@Angelodaniel Angelodaniel reopened this Jul 8, 2024
@romtsn
Copy link
Member

romtsn commented Jul 9, 2024

@ZeeshanShabbir could you post a little bit more log output? Is the uploadSentryProguardMappings${Variant} task not executed again?

@ZeeshanShabbir
Copy link
Author

@romtsn Yeah I coudn't find the uploadSentryProguardMappings${Variant} task in build logs.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jul 9, 2024
@kahest kahest moved this from Done to Needs Investigation in Mobile & Cross Platform SDK Jul 11, 2024
@kahest kahest moved this from Needs Investigation to Needs Discussion in Mobile & Cross Platform SDK Jul 11, 2024
@markushi markushi moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Jul 17, 2024
@stefanosiano stefanosiano assigned romtsn and unassigned markushi Aug 7, 2024
@Angelodaniel
Copy link
Member

Hey @romtsn, did you manage to have any update on this 🙏

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 30, 2024
@ZeeshanShabbir
Copy link
Author

Hi @romtsn, it's been a while. Do we have any update or estimate on when this issue will be resolved?

@markushi markushi assigned markushi and unassigned romtsn Oct 9, 2024
@markushi
Copy link
Member

After some investigation I unfortunately have to conclude that our Sentry Android Gradle Plugin won't work with DexGuard for now. The reason is quite simple: DexGuard runs very late in the build process, giving our Plugin no chance to inject the required mapping UUID based on the output of DexGuard.

For an DexGuard enabled app, the task graph looks like the following. As you can see, our sentry tasks runs way too early:

:app:assembleRelease
+--- :app:dexguardApkRelease
...
|    \--- :app:packageRelease
...
|         +--- :app:compressReleaseAssets
|         |    +--- :app:injectSentryDebugMetaPropertiesIntoAssetsRelease <-- would need to run after dexguard in order to work properly
|         |    |    +--- :app:generateSentryProguardUuidRelease
|         |    |    \--- :app:mergeReleaseAssets

If we would run our tasks after DexGuard, it would also mean that we'd need to re-package and re-sign the app, which seems to be a bigger and brittle effort. Let me reach out to folks from DexGuard, maybe we can work on a solution together.

In the meantime you can work around this issue by injecting a matching UUID yourself.

  1. Add a meta entry for the mapping-uuid to AndroidManifest.xml
<application>
    <meta-data
        android:name="io.sentry.proguard-uuid"
        android:value="${sentryProGuardUuid}" />
  1. Extend your app/build.gradle file

This provides the sentryProGuardUuid manifest placeholder value on a per-variant basis. On top of that a custom sentry-cli upload task is defined.

android.applicationVariants.configureEach { variant ->

    var flavor = variant.getMergedFlavor()

    // Add additional identifiers if necessary, e.g. git commit hash, GITHUB_RUN_ID / GITHUB_RUN_NUMBER
    var identifier = "${variant.applicationId}-${variant.versionCode}-${variant.versionName}-${variant.name}"
    var proguardUuid = UUID.nameUUIDFromBytes(identifier.getBytes(Charset.forName("UTF-8"))).toString()

    // set mapping uuid as placeholder for AndroidManifest.xml
    flavor.manifestPlaceholders = ["sentryProGuardUuid": proguardUuid]

    // custom upload task, requires sentry-cli to be installed
    tasks.register("uploadSentryMappings${variant.name.capitalize()}", Exec) {
        commandLine(
                "sentry-cli",
                "upload-proguard",
                "--uuid",
                proguardUuid,
                project.layout.buildDirectory.dir("outputs/dexguard/mapping/apk/${variant.name}/mapping.txt").get().toString(),
                "--version-code",
                variant.versionCode.toString(),
                "--app-id",
                variant.applicationId,
                "--version",
                variant.versionName
        )

        // path to the sentry.properties file, defining org and project
        var propertiesPath = new File(project.layout.projectDirectory.asFile.parentFile, "sentry.properties")
        environment("SENTRY_PROPERTIES", propertiesPath.toString())

        // if not set already, define the auth token for upload here
        // environment("SENTRY_AUTH_TOKEN", "<auth-token>")
    }
}
  1. Build your app and upload the mapping file
./gradlew :app:assembleRelease && ./gradlew :app:uploadSentryMappingsRelease

@shinayser
Copy link

shinayser commented Oct 14, 2024

e meantime you can work around this issue by injecting a matching UUID yourself.

Thanks @markushi for such great response. The point is only injecting a matching UUID on the manifest and using the same UUID for uploading, right?

My question is because we have a different pipeline and I was wondering if we could pass this "uuid" as an ambient variable to the Gradle and then execute the sentry-cli in our GitLab pipeline, using the same variable for upload.
We wish to not use gradle for uploading the files, but using our pipeline directly.

Does my plan make sense?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Oct 14, 2024
@markushi
Copy link
Member

Thanks @markushi for such great response. The point is only injecting a matching UUID on the manifest and using the same UUID for uploading, right?

My question is because we have a different pipeline and I was wondering if we could pass this "uuid" as an ambient variable to the Gradle and then execute the sentry-cli in our GitLab pipeline, using the same variable for upload. We wish to not use gradle for uploading the files, but using our pipeline directly.

Does my plan make sense?

Yes, you're right: It's all about injecting a matching UUID. It doesn't really matter who/how the UUID is generated. As long as it ends up in the AndroidManifest.xml (or is set via SentryOptions.setProguardUuid()) and matches the one being used to upload the mapping file, you'll be fine.

The Sentry Android Gradle Plugin is using sentry-cli under the hood for uploading the mapping file, so if you use sentry-cli directly, there should be no difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Platform: Android Sync: Jira apply to auto-create a Jira shadow ticket
Projects
Status: No status
Status: Needs Investigation
Development

No branches or pull requests

7 participants