1

I enabled proguard for my project and got the following error:

01:25:13.221 [ERROR] [org.gradle.BuildExceptionReporter] > java.io.IOException: proguard.ParseException: Expecting opening '(' or separator ';' before '{' in line 147 of file '/blalblah/proguard-rules/release/aapt_rules.txt'

The mentioned line indeed looks funny:

# onClick res/layout/host_entry.xml #generated:35
-keepclassmembers class * { *** ${()->cb.onDeleteClicked(host)}(...); }

Which looks like some copypaste from my layout:

        <ImageButton
        ....
        android:onClick="${()->cb.onDeleteClicked(host)}" />

So some proguard config generator thinks that only some method name can specified as onClick value and just puts the expression to the proguard config.

Is it possible to make it work without getting rid of nice lambda onclick handlers?

Equidamoid
  • 1,447
  • 1
  • 13
  • 24

1 Answers1

4

AAPT behaves correctly here. It is configured to ignore databinding expression values for the Proguard config generation. But yours is not a databinding expression:

android:onClick="${()->cb.onDeleteClicked(host)}"

Instead you have to use @{}:

android:onClick="@{()->cb.onDeleteClicked(host)}"

${} is an unsupported shell expression.

tynn
  • 38,113
  • 8
  • 108
  • 143