0

I am using minifyEnabled true in build.gradle (for obfuscation and size reduction purposes).

I have these proguard-rules.pro:

-keep class com.some3rdpartylibrary.** { *; } // otherwise it crashes

# repack obfuscated classes into single package so it would be hard to find their original package
-repackageclasses ''
-allowaccessmodification // this one is causing run-time crash in the 3rd party library

How can I tell proguard/R8 to dontallowaccessmodification just for com.some3rdpartylibrary.**?

c0dehunter
  • 6,412
  • 16
  • 77
  • 139
  • 1
    I am from the R8 team. It is not possible to limit the scope of `-allowaccessmodification`. It is a global flag. The current implementation of `-allowaccessmodification` in R8 will make all non-kept members public, and that can cause issues with package-private final methods that can result in runtime errors - probably what you are seeing. Right now keeping the methods causing issues is the only workaround. If possible open an issue on https://issuetracker.google.com/issues/new?component=326788&template=1025938? Maybe with some more details on the runtime error. – sgjesse Sep 23 '20 at 06:35
  • @sgjesse How can I keep the method? Error is `Caused by: java.lang.LinkageError: Method void com.some3rdpartylibrary.screens.payoutCard.presentation.cardInput.presentation.CardInputViewModel.clear() overrides final method in class Lxf; (declaration of 'com.some3rdpartylibrary.screens.payoutCard.presentation.cardInput.presentation.CardInputViewModel' appears in base.apk)`. – c0dehunter Sep 23 '20 at 10:52
  • To just keep `com.some3rdpartylibrary.screens.payoutCard.presentation.cardInput.presentation.CardInputViewModel.clear()` you can use `-keep class com.some3rdpartylibrary.screens.payoutCard.presentation.cardInput.presentation.CardInputViewModel { clear(); }`. Does that single keep solve the problem? – sgjesse Sep 24 '20 at 10:06
  • @sgjesse interestingly the crash persists, with the same log message. If I remove `-allowaccessmodification` it works. Also, since I have the rule `-keep class com.some3rdpartylibrary.** { *; }` shouldn't this already include `com.some3rdpartylibrary.screens.payoutCard.presentation.cardInput.presentation.CardInputViewModel { clear(); }`? – c0dehunter Sep 24 '20 at 19:19

0 Answers0