Open shamnad-sherief opened 4 days ago
@shamnad-sherief Have you added the proguard rules for the Razorpay SDK? You can find these here.
@shamnad-sherief Have you added the proguard rules for the Razorpay SDK? You can find these here.
I followed the ProGuard rules provided in the Razorpay documentation, but unfortunately, I didn't see any reduction in the app size. The APK size remains at 82MB, whereas it was only 30MB approx before. It seems like the rules suggested by Razorpay (like -dontwarn com.razorpay. and -keep class com.razorpay. {*;}) are functionally similar to the ones I was already using, which came from the missing_rules.txt file generated by R8.
The provided rules ensure that the necessary Razorpay classes and methods are retained, and suppress any warnings, but they don't seem to address the increase in size. Could it be that something else in the SDK or project is contributing to the large APK size? Any further insights or recommendations would be greatly appreciated.
Using a rule like -keep class com.razorpay.** {*;}
is not a good solution but more a workaround. The Razorpay team should spend some time to find more precise rules instead of just keeping everything.
The -dontwarn
rules are not relevant to size but only to suppress warnings for using APIs which are not present in any dependencies.
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /development/project/build/app/outputs/mapping/release/missing_rules.txt. ERROR: R8: Missing class proguard.annotation.Keep (referenced from: com.razorpay.AnalyticsEvent and 8 other contexts) Missing class proguard.annotation.KeepClassMembers (referenced from: com.razorpay.AnalyticsEvent and 8 other contexts)
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:minifyReleaseWithR8'.
A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable Compilation failed to complete
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
BUILD FAILED in 9s Running Gradle task 'assembleRelease'... 10.4s Gradle task assembleRelease failed with exit code 1
I also have same issue
Create a file in app folder proguard-rules.pro in this file write some code below-
-keep class io.flutter.app. { *; } -keep class io.flutter.plugin.* { ; } -keep class io.flutter.util. { *; } -keep class io.flutter.view. { *; } -keep class io.flutter.* { ; } -keep class io.flutter.plugins. { *; } -keep class com.google.firebase.* { ; } -dontwarn io.flutter.embedding.** -ignorewarnings
it's working for me. Thanks
After switching to flutter 3.24, I am experiencing an issue with the Razorpay SDK while building my project with R8 minification enabled. The build fails with the following error related to missing ProGuard annotations:
It seems that the
com.razorpay.AnalyticsEvent
and other classes are referencingproguard.annotation.Keep
andproguard.annotation.KeepClassMembers
, but these classes are not available during the R8 minification process. I have already tried adding ProGuard rules to retain these classes, but the issue persists.Steps to Reproduce:
release
build configuration.Environment Details:
Additional Information:
Workaround:
To work around the issue, I added additional keep rules that were generated in the following file: //build/app/outputs/mapping/release/missing_rules.txt
Here are the rules I added to proguard-rules.pro:
Result:
While this workaround allows me to build the project without minification, the app size has significantly increased, which is not ideal for production.