Conflict between Android data binding and Guava ca

2019-04-06 21:12发布

I get the following error while compiling my Android app with ProGuard enabled.

Warning: library class android.databinding.tool.util.SourceCodeEscapers$1 
    extends or implements program class com.google.common.escape.CharEscaper
Warning: library class android.databinding.tool.util.SourceCodeEscapers$JavaCharEscaper 
    extends or implements program class com.google.common.escape.ArrayBasedCharEscaper
Warning: library class android.databinding.tool.util.SourceCodeEscapers$JavaCharEscaperWithOctal 
    extends or implements program class com.google.common.escape.ArrayBasedCharEscaper
Warning: there were 3 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)

It appears that this is caused by a conflict between Android data binding and Guava. My app depends on Guava (com.google.guava:guava:18.0) and has data binding enabled. It appears that data binding has some sort of internal dependency on Guava and that is causing a problem with ProGuard.

I am running the latest beta version of gradle (2.0.0-beta5) so perhaps the problem is related to that.

1条回答
萌系小妹纸
2楼-- · 2019-04-06 21:12

So I was able to Build by adding this to proguard: -dontwarn android.databinding.** -keep class android.databinding.** { *; }

Which I don't think is entirely the right solution to just ignore those classes but I think we might just have to wait for an update from Google. After adding that to proguard I was able to build a release apk but it was crashing, I thought it was still proguard but found other errors in my code.

查看更多
登录 后发表回答