-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
New sample with min api level #2117
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- New sample with min api level ([#2117](https://github.com/getsentry/sentry-java/pull/2117)) If none of the above apply, you can opt out of this check by adding |
@@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issue for this module, but for some reason, it requires the baseline, likely a bug.
@@ -8,6 +8,7 @@ plugins { | |||
id(Config.QualityPlugins.errorProne) | |||
id(Config.QualityPlugins.gradleVersions) | |||
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion | |||
id(Config.QualityPlugins.androidLint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java projects can add the Android lint but I could not find a way to configure it using lint {}
cus android {}
does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apollo is also available for non Android, not sure how we would add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adinauer what do you mean? This is the Apollo module and I'm adding the lint
to it, so it's alright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I was trying to say that we probably can't just add the android plugin to it to gain android {}
in there as this can also be used by non Android applications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah gotcha, that's not the problem, lint
is already being applied to this module as a non-Android project, and it's being executed, I just can't change the default options apparently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we simply run grep on the logs instead and check for minApi warnings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But which logs do you want to run grep on? You need to be able to run lint first :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it works but we can't customize it to fail the build for minSdk violations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Linter runs already, but it does not check for newApi
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/open-toast/gummy-bears
This can help
have you used/tried this @romtsn @markushi ?
implementation(projects.sentryAndroid) | ||
implementation(projects.sentryAndroidFragment) | ||
implementation(projects.sentryAndroidTimber) | ||
implementation(projects.sentryApollo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So all projects with lower API is here
@@ -15,7 +16,7 @@ | |||
@ApiStatus.Experimental | |||
public final class Baggage { | |||
|
|||
static final @NotNull String CHARSET = "UTF-8"; | |||
static final @NotNull String CHARSET = StandardCharsets.UTF_8.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason this is not being detected, I guess AGP regressed here.
Warning: Lint will treat :sentry as an external dependency and not analyze it.
- Recommended Action: Apply the 'com.android.lint' plugin to java library project :sentry. to enable lint to analyze those sources.
The linter is able to analyze and check everything but does not consider the minApi
apparently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should revert this change and merge it anyway since I found out other issues with the linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this means we'll have to be careful and check manually in Android Studio if there's any minApi breakages we introduced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't find a fix for this, yes, which sucks, this used to work.
@romtsn ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it's not a bug, it's a deliberate decision from them not to run this check on non-android projects, because they cannot infer the minSdkVersion from a jvm-lib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to work in the past, so I'd consider either a bug or a non-documented breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, maybe, I checked the git history all the way to 2018 it was still there. Dunno how it would work on non-android projects, since they don't know the min sdk. Maybe you could ask on the issue tracker, but I guess we'd need to have some workaround like I mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's strange, I'm pretty sure that it worked in the past when developing sentry-android v2 unless I'm mistaken, I don't recall leaking NewApi tho so I strongly think that it worked in the past.
We could try this workaround, it's a good idea.
I just quickly tried and it requires a bit of more work, I'd stop here tho, feel free to add this to our backlog and eventually prioritize finishing up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, @adinauer or I could take it from there, thanks 👍
Codecov Report
@@ Coverage Diff @@
## main #2117 +/- ##
============================================
- Coverage 80.92% 80.85% -0.07%
+ Complexity 3253 2918 -335
============================================
Files 231 176 -55
Lines 11951 10545 -1406
Branches 1586 1433 -153
============================================
- Hits 9671 8526 -1145
+ Misses 1700 1509 -191
+ Partials 580 510 -70 Continue to review full report at Codecov.
|
"sentry-uitest-android", | ||
"sentry-uitest-android-benchmark", | ||
"sentry-samples-android-minsdk", | ||
// "sentry-samples-console", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert before merging
@@ -8,6 +8,7 @@ plugins { | |||
id(Config.QualityPlugins.errorProne) | |||
id(Config.QualityPlugins.gradleVersions) | |||
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion | |||
id(Config.QualityPlugins.androidLint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the reason I think - they do not run this check for non-android projects
https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ApiDetector.kt;l=645
I think we'd need to apply the android plugin and set minSdkVersion
in order for it to run.
@@ -8,6 +8,7 @@ plugins { | |||
id(Config.QualityPlugins.errorProne) | |||
id(Config.QualityPlugins.gradleVersions) | |||
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion | |||
id(Config.QualityPlugins.androidLint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could apply the com.android.library
plugin and the android {}
block conditionally (e.g. having a flag on CI) and run lint as a separate build stage/task, but still release the library as a jar (disable the flag for publish
task). Wdyt?
👋 |
Outdated, a new PR would make more sense. |
sry, never got to it. Does it still make sense to have a min-api-level sample or should we rather have an automated test running against the app with the min-api-level? I'm afraid I will never use this sample for my local testing |
📜 Description
💡 Motivation and Context
Fixes #1403
💚 How did you test it?
📝 Checklist
🔮 Next steps