I have updated fresco library version from 1.1.0 to 1.2.0 and tried to build the project with ProGuard.
It seems like the build fails due to the obfuscation of two specific annotations that fresco depends on, starting from 1.2.0, which are
com.facebook.infer.annotation.ReturnsOwnershipcom.facebook.infer.annotation.FunctionalThe error message is below:
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.common.util.TriState: can't find referenced class com.facebook.infer.annotation.Functional
Warning: com.facebook.drawee.controller.AbstractDraweeControllerBuilder: can't find referenced class com.facebook.infer.annotation.ReturnsOwnership
Warning: com.facebook.drawee.generic.GenericDraweeHierarchyInflater: can't find referenced class com.facebook.infer.annotation.ReturnsOwnership
....
FAILURE: Build failed with an exception.
The build fails for every attempt when updating fresco library version from 1.1.0 to 1.2.0.
The build succeeds if the library version is specified to 1.1.0.
@erikandre I think you did the last release and I think I recall you hitting some issues with these annotations as well. Can you take a look?
@shaunkawano what happens if you just tell proguard to keep those two classes?
@foghina Thank you for the quick response; adding these two dontwarn configuration fixes build failure and made the build to succeed for me.
-dontwarn com.facebook.infer.annotation.ReturnsOwnership
-dontwarn com.facebook.infer.annotation.Functional
Hopefully this is the minimum configuration required to make the build succeed, but still I am not 100% sure simply dontwarning them solves the entire issue here.
These annotations are only used by infer, so at lint time. They are not used at runtime at all. I think -dontwarn should be fine. I'll add this to the docs. Thanks!
Wait, looks like infer classes should already have -dontwarn, according to proguard-fresco.pro. @shaunkawano did you follow the proguard doc?
Oops..my bad; I haven't checked that documentation. Thanks for your info!
(By the way, in the future, possibly fresco could contain consumerProguardFiles configuration on its build.gradle file to include those ProGuard settings within the library itself so that users may no longer need to set up additional ProGuard setting on top of their own. :) (Glide seems to have done this already; I have pasted the code ref below as well).
Reference I have looked up:
Anyway, thanks for your quick response and help!
consumerProguardFiles sounds useful, we'll look into it.
PRs are also welcome ;)
Thanks! :)
Most helpful comment
Oops..my bad; I haven't checked that documentation. Thanks for your info!
(By the way, in the future, possibly fresco could contain
consumerProguardFilesconfiguration on its build.gradle file to include those ProGuard settings within the library itself so that users may no longer need to set up additional ProGuard setting on top of their own. :) (Glide seems to have done this already; I have pasted the code ref below as well).Reference I have looked up:
Anyway, thanks for your quick response and help!