CLOSED
We are trying to integrate android library (which is compiling android support library) in our project that has been migrated to androidX. And for unknown reason we are getting
can't find referenced method 'void addOnTabSelectedListener(com.google.android.material.tabs.TabLayout$OnTabSelectedListener)' in program class com.google.android.material.tabs.TabLayout
while trying to get a proguard enabled build.
gradle-wrapper: 4.8
gradle build tools : 3.2.0
compileSdkVersion 28
EDIT 9-Oct-2018
For some reason, it was a proguard issue, proguard was showing wrong error, after we made some changes in our sourcecode, and forgot to add some classes to proguard, it changed the errors with the classes that we forgot to add. and after adding them everything went good.
To debug Proguard/R8 configuration, navigate to app\build\outputs\mapping\release. There we can see the following files: configuration. txt – merged file with all configurations – from the app, default Android, AAPT, all the libraries, etc.
January 11, 2022. R8 is a tool that is used to shrink, secure, and optimize Android applications. It uses proguard rules to change the behavior of application.
To enable R8 shrinking in your application, set the minifyEnabled to true in your app's main build. gradle file.
I think that you should tell to proguard to not obfuscate material classes. But this is just a workaround, you have some other issue so try to fix it.
Try to add these lines in your proguardrules.pro file:
-keep class com.google.android.material.** { *; }
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
Then, in your build.gradle
buildscript {
repositories {
maven {
url "http://storage.googleapis.com/r8-releases/raw/master"
}
}
dependencies {
classpath 'com.android.tools:r8:ff9c89416cc1c8adf83d481a1e5fd515fcb893b9'
classpath 'com.android.tools.build:gradle:your version'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With