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

Add Proguard rules for React Native's Reanimated library #16578

Merged
merged 1 commit into from
May 17, 2022

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented May 17, 2022

This PR fixes a crash related to dragging a block in the editor.

To test

Preparation:

Proguard rules are only applied in the release version, so in order to test the change properly, it's required either to build the app in release mode or build the app locally and enable Proguard by applying the following patch.

diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java
index 2958b8947312f5fad0aa26edf94d6b52855961c2..12c3f2e9d20c0a878545b27277fa74c4452abc0f 100644
--- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java
+++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java
@@ -126,7 +126,7 @@ public class GutenbergContainerFragment extends Fragment {
         mWPAndroidGlueCode.onCreateView(
                 getContext(),
                 getActivity().getApplication(),
-                BuildConfig.DEBUG,
+                false,
                 getContext().getResources().getColor(R.color.background_color),
                 exceptionLogger,
                 breadcrumbLogger,
diff --git a/WordPress/build.gradle b/WordPress/build.gradle
index c2ffda71dc2f6c77f3f16218e0a25d7c034338cd..303a8f8704238d937fafd87a963c9b17fb4703fd 100644
--- a/WordPress/build.gradle
+++ b/WordPress/build.gradle
@@ -250,8 +250,8 @@ android {
         }
 
         debug {
-            minifyEnabled false
-            buildConfigField "String", "APP_PN_KEY", "\"org.wordpress.android.debug.build\""
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
         }
     }
 
@@ -666,4 +666,4 @@ if (project.hasProperty("debugStoreFile")) {
 
 // Keep this at the bottom (https://stackoverflow.com/a/37565535)
 apply plugin: 'com.google.gms.google-services'
-apply plugin: 'io.sentry.android.gradle'
+// apply plugin: 'io.sentry.android.gradle'

Testing instructions:

  1. Open a post/page
  2. Add some blocks.
  3. Long-press over a block to start the drag mode.
  4. Observe that the app does not crash.
  5. Observe that the block can be moved around the block list.
  6. Drop the block in the desired location.
  7. Observe that the block is moved to the desired location.

Regression Notes

  1. Potential unintended areas of impact
    This PR only adds a couple of Proguard rules so there are no potential unintended areas of impact.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    N/A

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile
Copy link

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 4 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

Comment on lines +76 to +77
-keep class com.swmansion.reanimated.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rules have been added following the installation guide of the Reanimated library:
https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/#proguard

@fluiddot fluiddot requested a review from mchowning May 17, 2022 16:10
@peril-wordpress-mobile
Copy link

You can test the changes on this Pull Request by downloading the APKs:

Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good. I did a release build locally and observed that dragging and dropping was working great! 🎉

@fluiddot fluiddot merged commit f32c60f into release/19.9 May 17, 2022
@fluiddot fluiddot deleted the fix/reanimated-library-proguard-rules branch May 17, 2022 16:32
@AliSoftware
Copy link
Contributor

This fix has now been shipped as part of the 19.9-rc-2 beta 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants