Open PaulWoitaschek opened 2 years ago
@PaulWoitaschek are you using proguard
or r8
? are you using any special configuration in your proguard config?
Can you add to your app's proguard file:
// You can specify any path and filename.
-printconfiguration ~/tmp/full-r8-config.txt
And check if the rule to keep SentryAndroidOptions
is there?
https://github.com/getsentry/sentry-java/blob/e4a46aa6dfe09aa185f1aaf6bd31235c12b520db/sentry-android-ndk/proguard-rules.pro#L5-L7
Thanks.
It does not exist.
But wait; we're not using sentry-android-ndk. It seems the plugin adds that, where we add the 6.0.0 core dependency.
Maybe this is related to the plugin adding an outdated dependency?
Yes, confirmed. Setting the version in the autoInstallation block fixes it.
I think this is a dependency issue: In a gradle module we have a dependency on sentry-core using 6.0.0. Now the plugins in the app module adds 5.7.0.
In the final dependeny graph this leads to inconsistent dependencies:
+--- io.sentry:sentry-android:5.7.0
| +--- io.sentry:sentry-android-core:5.7.0 -> 6.0.0
| | \--- io.sentry:sentry:6.0.0
| \--- io.sentry:sentry-android-ndk:5.7.0
| +--- io.sentry:sentry:5.7.0 -> 6.0.0
| \--- io.sentry:sentry-android-core:5.7.0 -> 6.0.0 (*)
Disabling the auto installation also works.
From your side this coulde be mitigated by publishing a bom. The approach could look like this: You publish a bom. The plugin applies the bom. The plugin uses now either uses the plugin defined version for the bom or (with precedence) the user supplied sentry version and applies the bom using that version.
We do publish a bom already -> https://docs.sentry.io/platforms/android/configuration/bill-of-materials/. I'm not sure the bom would help here though, because if we apply the bom with the version 5.7.0
, this still would be a problem for your case, because you specify explicitly the -core
version of 6.0.0
, so the ndk would still be applied with 5.7.0, wouldn't it?
Ideally we'd look at your dependency tree and use the version that you've specified in the module, but that's unfortunately not possible without resolving the configuration, and this can be quite heavy for the build time (we have an improvement to at least warn you about that though (https://github.com/getsentry/sentry-android-gradle-plugin/issues/324).
There are also other multiple improvements to this:
-core
package is installed by default)From my understanding, an applied enforcedPlatform
would do it.
Besides that, moving the plugin and the java library to the same repository and releasing them with the same version would mitigate these errors (where plugin and lib are out of sync) as well.
Ah, I wasn't aware of enforcedPlatform
, yeah it seems like that would do.
We actually wanted to be conservative here, and do not override any of the user-defined dependencies, but maybe it'd be better to have them enforced (e.g. by using a bom and giving user an option to specify a version) @bruno-garcia @marandaneto wdyt?
Ah, I wasn't aware of
enforcedPlatform
, yeah it seems like that would do.We actually wanted to be conservative here, and do not override any of the user-defined dependencies, but maybe it'd be better to have them enforced (e.g. by using a bom and giving user an option to specify a version) @bruno-garcia @marandaneto wdyt?
Problem of us overriding the version is that user can't override our behavior it turns out to be wrong. Could we log a build warning instead? Or have a separate option to disable our overriding behavior if we add it?
In general, the approach to let users overwrite versions is good.
But in the case that you use auto-install, it is error prone and leads to inconsistent versions (which has caused the crash I'm reporting). And you can explicitly set the version in the auto install extension already so I expect this to solve more issues than it causes.
Problem of us overriding the version is that user can't override our behavior it turns out to be wrong. Could we log a build warning instead?
It's kind of possible through autoInstallation.sentryVersion
config, but it will set a single version for all integrations. The only problem I see with this, is if they want to keep an older version of, say, -timber
, while updating -core
to 6.0.0. But this still would be possible to enforce via gradle's dependency resolution.
Or have a separate option to disable our overriding behavior if we add it?
Having an option for that is also possible, yep.
Ah, I wasn't aware of
enforcedPlatform
, yeah it seems like that would do.We actually wanted to be conservative here, and do not override any of the user-defined dependencies, but maybe it'd be better to have them enforced (e.g. by using a bom and giving user an option to specify a version) @bruno-garcia @marandaneto wdyt?
Yep, we should not override the user-defined dependencies to not force the need of upgrading the Sentry SDK nor the need of removing the Sentry Gradle plugin due to not being compatible.
Problem of us overriding the version is that user can't override our behavior it turns out to be wrong. Could we log a build warning instead?
It's kind of possible through
autoInstallation.sentryVersion
config, but it will set a single version for all integrations. The only problem I see with this, is if they want to keep an older version of, say,-timber
, while updating-core
to 6.0.0. But this still would be possible to enforce via gradle's dependency resolution.Or have a separate option to disable our overriding behavior if we add it?
Having an option for that is also possible, yep.
All Sentry packages should be the very same version, we should not allow the mix of e.g. sentry-android-core 5.7 and sentry-android-timber 6.0, packages are published together with the very same version to avoid incompatibilities.
If the user defined 5.7.0 in its dependencies block (it doesn't matter if its the core package or not, versions should be aligned), we should keep using 5.7.0, if this is technically not possible or too expensive, I'd say we should turn off the auto-install for this use case.
If the user defined the sentryVersion
, then we respect that.
Moved this to the SAGP repo, as it rather belongs here.
@PaulWoitaschek we've released 3.1.1
which bumps the runtime sdk version to 6.1.0
, so this problem should be gone, but we'll look into a more future-proof solution. Thanks for your ideas and the bug report!
We could have a gradle task which looks over the dependency tree and see if there are mismatched sentry packages' versions, fail the build or show a warning.
Integration
sentry-android
Build System
Gradle
AGP Version
7.2.1
Proguard
Enabled
Version
6.0.0, plugin=3.1.0
Steps to Reproduce
Build an obfuscated release build and call:
Expected Result
It doesn't crash
Actual Result
Follow up of the discussion in https://github.com/getsentry/sentry-java/pull/2031
Calling
options.isEnableNdk = false
causes the crash to not appear.Stacktrace