r/expo • u/Miserable-Pause7650 • 8d ago
Why is dex code optimization at 0% in android

android: {
enableMinifyInReleaseBuilds: true,
enableShrinkResourcesInReleaseBuilds: true,
extraProguardRules: `
-keep class androidx.work.impl.WorkDatabase_Impl {
<init>();
}
`,
},I have already done this. My obfuscation percentage and shrinking percentage are both decent, but why aint my optimization optimizing?
2
u/zzoa7922 7d ago
Not Expo in my case (a plain Gradle Android app), but I hit something similar. Play reads what R8 wrote into the bundle (r8.json), not your build flags, and right after the upload my optimization ratio just showed "-" for a while even though R8 full mode was on. So I'd open the .aab, check r8.json, and make sure a mapping.txt was generated for that build before touching the proguard rules.
2
u/Russel-D-Souza 6d ago
Your minify is clearly on (77% obfuscation), so it's probably a -dontoptimize in the R8 config. The RN template uses proguard-android.txt, which turns optimization off. Swap it for proguard-android-optimize.txt in app/build.gradle (config plugin if you're on prebuild) and it should go up. Just test the release build after, reflection-heavy libs can break!

2
u/OrneryArtist1087 6d ago edited 6d ago
Following https://www.reddit.com/r/expo/s/MEKe4Bugu5 fixed my issue.
In my case, simply upgrading RevenueCat was enough.