'Android Studio prevent successful compile when an annotation is missing

I detect in my project a linter error.

Call requires API level 26 (current min is 23): java.time.format.DateTimeFormatter#format
@Add RequiresApi(O) Annotation

I'm wondering why my project is compiling. Because the app crashs on devices which have a smaller API level than 26.

Fixing the problem wasn't hard, but of course I wonder if there are any other RequiresApi-Annotation (or errors). So Android Studio is really clever and warns me. But I would prefer that I get a compiler error.

I was searching a while but I cannot find how to configure that. Does anybody know how can I prevent a successful compilation when there are so important annotation warnings/errors?



Solution 1:[1]

It's not a super solution. But you can just press Analyze -> Inspect Code -> Whole Project and in the output you see all errors.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kuzdu