-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[linear-gradient] fix crash when r8 enabled #21580
Conversation
Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines. I've found some issues in your pull request that should be addressed (click on them for more details) 👇
|
@@ -22,6 +24,8 @@ public class LinearGradientView extends View { | |||
private int[] mSize = {0, 0}; | |||
private float[] mBorderRadii = {0, 0, 0, 0, 0, 0, 0, 0}; | |||
|
|||
// Keeps this primary constructor from Proguard/R8 for ViewDefinitionBuilder | |||
@Keep |
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 there any difference between @keep and @DoNotStrip?
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.
good catch! though @keep is the default androidx annotation and R8 has default rules to keep it, using @DoNotStrip is more aligned to our code base.
# Why fixes #21562 # How the code here will be stripped by R8: https://github.com/expo/expo/blob/4d234bbfb32b66b3944a0e652eda1e6c67287059/packages/expo-linear-gradient/android/src/main/java/expo/modules/lineargradient/LinearGradientView.java#L25-L27 and then our `ViewDefinitionBuilder` cannot find the primary constructor. this pr adds the keep annotation. i didn't find a way to fix it systematically from expo-modules-core. let's address case by case and expo-linear-gradient first. # Test Plan https://github.com/GaelCO/repro_linearGradient with patch-package for the fix (cherry picked from commit 36421ad)
Why
fixes #21562
How
the code here will be stripped by R8:
expo/packages/expo-linear-gradient/android/src/main/java/expo/modules/lineargradient/LinearGradientView.java
Lines 25 to 27 in 4d234bb
ViewDefinitionBuilder
cannot find the primary constructor. this pr adds the keep annotation.i didn't find a way to fix it systematically from expo-modules-core. let's address case by case and expo-linear-gradient first.
Test Plan
https://github.com/GaelCO/repro_linearGradient with patch-package for the fix
Checklist
expo prebuild
& EAS Build (eg: updated a module plugin).