From 16375807327ec8e94cde91a7cbee771c48bf0c69 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Tue, 3 Jan 2023 20:29:10 +0530 Subject: [PATCH] Include proguard config (#1842) This will remove the requirement for people to add the proguard configs themselves. A lot of people first release to production with proguard and then realize why the app crashes. This will solve such issues. This uses android's consumer proguard setting to enable specific proguard config. --- README.md | 23 ----------------------- android/build.gradle | 2 ++ android/proguard-rules.pro | 1 + 3 files changed, 3 insertions(+), 23 deletions(-) create mode 100644 android/proguard-rules.pro diff --git a/README.md b/README.md index efde392e..725fad6b 100644 --- a/README.md +++ b/README.md @@ -87,29 +87,6 @@ expo install react-native-svg ## Troubleshooting -### Problems with Proguard - -When Proguard is enabled (which it is by default for Android release builds), it causes runtime error. -To avoid this, add an exception to `android/app/proguard-rules.pro`: - -```bash --keep public class com.horcrux.svg.** {*;} -``` - -If you have build errors, then it might be caused by caching issues, please try: - -```bash -watchman watch-del-all -rm -fr $TMPDIR/react-* -react-native start --reset-cache - -Or, - -rm -rf node_modules -yarn -react-native start --reset-cache -``` - ### Unexpected behavior If you have unexpected behavior, please create a clean project with the latest versions of react-native and react-native-svg diff --git a/android/build.gradle b/android/build.gradle index 9c4dd566..e7b0d7a2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -54,6 +54,8 @@ android { //noinspection OldTargetApi targetSdkVersion safeExtGet('targetSdkVersion', 28) buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() + + consumerProguardFiles 'proguard-rules.pro' } lintOptions { abortOnError false diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 00000000..19f9ddeb --- /dev/null +++ b/android/proguard-rules.pro @@ -0,0 +1 @@ +-keep public class com.horcrux.svg.** {*;}