Skip to content

Compilation error with ProGuard enabled due to FindBugs annotation SuppressFBWarnings #1011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Whathecode opened this issue Oct 20, 2021 · 9 comments
Labels
bug Something isn't working
Milestone

Comments

@Whathecode
Copy link

Whathecode commented Oct 20, 2021

Describe the bug
Using ProGuard 7.2.0-beta2 and ObjectBox 3.0.1, I get the following ProGuard warning during compilation:

Warning: io.objectbox.ideasonly.ModelModifier$PropertyModifier: can't find referenced class edu.umd.cs.findbugs.annotations.SuppressFBWarnings

Seemingly the SuppressFBWarnings class on ModelModifier.PropertyModifier can't be found. Since this seems part of a static analysis for FindBugs, I can simply disable the warning using the following proguard rules:

-dontwarn io.objectbox.ideasonly.ModelModifier$PropertyModifier

Basic info (please complete the following information):

  • ObjectBox version: 3.0.1
  • Reproducibility: always

Expected behavior
For this to work out-of-the-box. Perhaps by including the dontwarn rule in the packaged objectbox-java.pro.

Additional context
I am currently upgrading from ProGuard which is integrated as part of the Android Gradle Plugin 7.1.0-beta1 to the separate Proguard Gradle Plugin in order to see whether the latest version resolves a potential obfuscation bug I am running into. Therefore, I have currently enabled ProGuard on my debug build. Not certain whether this impacts ObjectBox, but figured this might be relevant to mention. Regardless, I just also tested in release, and the same warning shows up.

@Whathecode Whathecode added the bug Something isn't working label Oct 20, 2021
@greenrobot-team
Copy link
Member

Thanks. Your title says compilation error, but the message indicates it is only a warning. Are you sure that warning is the cause of the error? Or does the app actually compile?

Anyhow, yes, we should probably add a dontwarn rule for the SpotBugs annotations.

@greenrobot-team
Copy link
Member

@Whathecode Just to make clear, this warning only happens with a separate ProGuard plugin (7.2.0-beta2)? I failed to repro with Android Gradle Plugin 7.1.0-beta1.

As the affected class isn't used anywhere this might be a ProGuard regression...

@greenrobot-team greenrobot-team added this to the Future release milestone Nov 2, 2021
@greenrobot-team
Copy link
Member

Next update will add this rule:

-dontwarn edu.umd.cs.findbugs.annotations

@Whathecode Can you verify if this one also works?

@Whathecode
Copy link
Author

I can check, but I doubt it. Afaik the -dontwarn rule needs to specify the class from where the warning originates. It doesn't filter out warnings for missing classes.

@Whathecode
Copy link
Author

On top of that, edu.ud.cs.findbugs.annotations is an incomplete class filter. If what is intended is all classes in that namespace you need to append .*, or .** to include deeper namespaces. Note that the only class that triggered a warning for me was the one I listed before.

As expected (stated in the previous message), the rule you suggest does not resolve the warning.

@greenrobot-team
Copy link
Member

You are right, mixed up syntax.
So

-dontwarn edu.umd.cs.findbugs.annotations.**

does not work as well? I vaguely remember adding a rule for a referenced class worked as well.

@Whathecode
Copy link
Author

Whathecode commented Dec 6, 2021

Just checked, and that indeed works!

Interesting. That is not clearly documented in the ProGuard documentation.

Wouldn't it still be better to then use the following more specific rule?

-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings

@greenrobot-team
Copy link
Member

Thanks for verifying! Next update will (actually) add the more specific rule:

-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings

@greenrobot-team greenrobot-team modified the milestones: Future release, 3.1.0 Dec 15, 2021
@greenrobot-team
Copy link
Member

This is included in the 3.1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants