-
Notifications
You must be signed in to change notification settings - Fork 841
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
Building animal sniffer signatures directly from android corelib #5973
Building animal sniffer signatures directly from android corelib #5973
Conversation
animal-sniffer/build.gradle.kts
Outdated
|
||
dependencies { | ||
signature("com.toasttab.android:gummy-bears-api-21:0.6.1@signature") | ||
signatureJar("com.android.tools:desugar_jdk_libs:2.0.4") |
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 tested that it works by adding some code that uses java.util.Base64
and then running the task animalsnifferMain
which completed without any issues (since Base64 was added in version 2.0.4
). Then I changed this version to 2.0.3
and re-run the animal sniffer task which then failed.
This is awesome! I'm on board with this approach. Gives us more control and centralizes the declaration of all the versions that comprise the android compatibility we ensure. |
I agree, very nice to be explicit about the desugaring version requirement 👍 |
Cool! I'll address the CI issues and move it to ready for review then 👍 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5973 +/- ##
============================================
+ Coverage 91.12% 91.18% +0.05%
- Complexity 5599 5613 +14
============================================
Files 615 616 +1
Lines 16519 16566 +47
Branches 1639 1642 +3
============================================
+ Hits 15053 15105 +52
+ Misses 1014 1013 -1
+ Partials 452 448 -4 ☔ View full report in Codecov by Sentry. |
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.
Just a couple of small comments. Thanks for doing this!
settings.gradle.kts
Outdated
@@ -64,6 +64,7 @@ include(":sdk-extensions:autoconfigure-spi") | |||
include(":sdk-extensions:incubator") | |||
include(":sdk-extensions:jaeger-remote-sampler") | |||
include(":testing-internal") | |||
include(":animal-sniffer") |
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.
How about animal-sniffer-signature?
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.
Sure no problem, I've made the changes.
animal-sniffer/build.gradle.kts
Outdated
|
||
repositories { | ||
mavenCentral() | ||
google() |
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.
Let's move google()
to the repositories section of settings.gradle.kts
, and delete mavenCentral()
since its redundant.
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.
Thanks, it's updated now.
animal-sniffer/build.gradle.kts
Outdated
|
||
dependencies { | ||
signature("com.toasttab.android:gummy-bears-api-21:0.6.1@signature") | ||
signatureJar("com.android.tools:desugar_jdk_libs:2.0.4") |
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.
Is it possible to define these in dependencyManagement/build.gradle.kts
and omit the versions here?
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 tried with both but it only worked for com.android.tools:desugar_jdk_libs
so that's the only one I moved over to dependencyManagement. I'm guessing the @signature
part of gummy-bears makes it difficult for Gradle to resolve the artifact when the version is defined elsewhere.
Android corelib or desugar_jdk lib is a jar containing missing JDK8 classes from Android OS versions below API 26. The idea is that apps targeting old Android devices, where said classes are missing, can add those into the app itself to avoid
NoClassDefFoundException
runtime errors in old devices. More info here.However, the corelib doesn't have ALL the JDK8 missing classes, so we need to make sure we don't use those in order to avoid Android runtime exceptions. That's where Animal Sniffer helps, by checking our codebase against a signature that contains all the info about the classes available at runtime in old Android devices, both from the OS itself and from the corelib as well.
Since the corelib version of gummy-bears is not currently up-to-date with the latest corelib/desugar lib changes from Google, these changes aim to locally generate our android animal sniffer signature directly from the android lib, while also extending gummy-bears' existing plain (without the corelib parts, just the OS runtime classes) signature by following this guide on how to create/extend signatures for animal sniffer.