20

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.

  • Check logic https://github.com/Instabug/Instabug-Android/issues/123 – IntelliJ Amiya Oct 01 '18 at 13:41
  • Did you migrate to AndroidX, Are you sure it is migrated? Which dependencies you have in `build.gradle`? Please add more information + dependencies. – ʍѳђઽ૯ท Oct 01 '18 at 13:55
  • @ʍѳђઽ૯ท it is the exact issue mentioned here https://github.com/Instabug/Instabug-Android/issues/123 – Mohamed Zakaria El-Zoghbi Oct 01 '18 at 14:00
  • It looks like your last edit actually contains the *answer* to the problem. In that case, the right action is to post an **answer** instead of editing. Please roll back and post your solution as an answer (then we can vote on that as well as on your question, so it's good for your reputation points, too!) – Toby Speight Oct 31 '18 at 14:09

1 Answers1

18

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'
    }
}
Rahul
  • 3,293
  • 2
  • 31
  • 43
Roberto Manfreda
  • 2,345
  • 3
  • 25
  • 39