Describe the bug
- Environment
- Platform: Android
- SDK version: Used via purchases-kmp version
2.10.2+17.55.1
- OS version: Irrelevent
- Android Studio version: Irrelevent
- How widespread is the issue: apps using AGP < 9 if I understand correctly
R8 recently shipped an analyzer which shows how good your app is shrinked/optimized/obfuscated. Running it on an app that uses RevenueCat leads to getting a scary looking score of 0% for optimization.
If I exclude the amazon module
// in android/app/build.gradle
configurations.configureEach {
exclude group: "com.revenuecat.purchases", module: "purchases-store-amazon"
}
The score is back to normal levels
Running lint on the app also raises a warning about it
../../../../../../../../.gradle/caches/9.5.1/transforms/f235dccd418e2ee34b196b2710a84e68/transformed/purchases-store-amazon-9.29.0/proguard.txt: The consumer keep rules at purchases-store-amazon-9.29.0/proguard.txt (from com.revenuecat.purchases:purchases-store-amazon:9.29.0) contains a global option which should not be specified in library consumer rules: -dontoptimize
Libraries often include consumer keep rules to instruct R8 how to optimize the library, especially if the library uses reflection. These keep rules typically indicate to R8 of which classes, methods and fields shouldn't be fully optimized so e.g. reflection continues to work.
Global keep rules can be used by an application to disable significant optimization features, debug R8 behavior, suppress warnings, etc. However, these global options should not be included in library consumer rules -- those distributed with a library.
Starting in Android Gradle Plugin version 9.0, all such rules are not supported in library builds, and ignored by application builds if included in a library. Libraries should not rely on these global options in consumer rules to function, and should remove them.
If you see a flagged library, first try to update to a newer version that doesn't have the embedded global rule. If an updated version without these global options is not available, contact the library vendor to ask about their plans to remove global options, and thus support better R8 configuration.
As an application developer using Android Gradle Plugin 9.0, verify that Android Gradle Plugin removing these global options isn't causing issues in your application. If they are, you can add them temporarily to a local keep rule file.
More info: https://developer.android.com/topic/performance/app-optimization/choose-libraries-wisely
To suppress this error, use the issue id "GlobalOptionInConsumerRules" as explained in the Suppressing Warnings and Errors section.
GlobalOptionInConsumerRules Correctness Warning Priority 2/10
I used r8 9.3.7-dev, which includes global options in its report.
According to the lint warning, this shouldn't be a problem for apps build with AGP 9+, as those flags are now ignored.
If I understand correctly, it still means that apps using AGP < 9 aren't getting optimized.
Additional context
https://developer.android.com/topic/performance/app-optimization/r8-configuration-analyzer
// <rootDir>/build.gradle
// to override r8
buildscript {
repositories {
maven { url = uri("https://storage.googleapis.com/r8-releases/raw") }
}
dependencies {
// https://r8.googlesource.com/r8/+/refs/heads/main/README.md#replacing-r8-in-agp
classpath(com.android.tools:r8:9.3.7-dev)
}
}
Describe the bug
2.10.2+17.55.1R8 recently shipped an analyzer which shows how good your app is shrinked/optimized/obfuscated. Running it on an app that uses RevenueCat leads to getting a scary looking score of 0% for optimization.
If I exclude the amazon module
The score is back to normal levels
Running lint on the app also raises a warning about it
I used r8
9.3.7-dev, which includes global options in its report.According to the lint warning, this shouldn't be a problem for apps build with AGP 9+, as those flags are now ignored.
If I understand correctly, it still means that apps using AGP < 9 aren't getting optimized.
Additional context
purchases-android/feature/amazon/consumer-rules.pro
Line 4 in 0857296
https://developer.android.com/topic/performance/app-optimization/r8-configuration-analyzer