0

I'd like to build obfuscated AAR library which makes use of Android data binding. When I use the library with minifyEnabled false my library build successfully and my testing app works , after enabling ProGuard the testing app doesn't compile since BR fields in the generated data binding classes can't be found.

Error: Cannot resolve type for vm

    In layout :: 
        <data>
          <variable
                name="vm"
                type="com.XXX.ViewModel"/>
        </data>

1 Answers1

2

add this lines Inside your Proguard file.

-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
-keep class android.databinding.annotationprocessor.** { *; }

source here

It Works for me.

Nikunj Paradva
  • 15,332
  • 5
  • 54
  • 65
  • I have already added above lines in my proguard:-keep public class **.BR { public *; } -keep public class **.BR$* { public *; } -keepclassmembers class **.BR$* { public static ; } -keepclassmembers class **.R$* { public static ; } -keep class android.databinding.** { *; } -keepattributes javax.annotation.processing.* -keep class * extends android.databinding.** { *; } -keep class com.pnb.aeps.sdk.databinding.** { public ; public ; } – Shailesh Tiwari Apr 04 '18 at 10:52
  • @user3337017 add this `keep class com.pnb.aeps.sdk.scanner.RowScanMachineViewModel` – Nikunj Paradva Apr 04 '18 at 11:02