Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Android lint check for the @Nullable annotation?

I've noticed that Android Studio will verify that @Nullable isn't being ignored in the code:

ex.

@Nullable MyObject getMyObject();
...

MyObject o = getMyObject();
o.method();

^ Method invocation 'method' may produce 'java.lang.NullPointerException'

This is enforced by the NullableProblems IntelliJ warning.

I would like to enforce this rule from gradle at build-time via lint rule. Does anyone happen to know if it's possible to enable something similar to that via gradle?

like image 777
Daniel Jette Avatar asked Jan 27 '17 15:01

Daniel Jette


1 Answers

If you want lint to throw an error when certain rules are broken in the source code, you can definitely configure the project in a way that the source compilation halts. I could have written the whole process but this link more or less summarizes the whole thing

Also go through the Android link doc

Note : Analyze option in Android Studio Menu mostly uses both Lint and built in Intellij Idea Code inspection

like image 166
Dibzmania Avatar answered Oct 31 '22 05:10

Dibzmania