What is the way out?
Well, since the javadoc implies that the method is not used anymore, one solution would be to implement it as follows:
@SuppressWarnings("deprecation")
public int getOpacity() {
throw new UnsupportedOperationException("getOpacity is deprecated");
}
Well, I'm running ./gradlew lint
so it should go in lint.xml
with severity=ignore
. But I don't want to suppress every deprecation warning either ...
I'm not sure it is possible, but you could try reading:
(It looks like the best you could do is suppress all deprecation warnings in specific classes or packages.)
Alternatively, you can selectively suppress specific deprecation warnings at the site where they are triggered; i.e. by adding @SuppressWarnings("deprecation")
annotations as shown above. For a once-off suppression this would be the simplest way.
If the deprecation warnings are coming from the Gradle lint
task rather than the javac
compiler, then you could use //noinspection
comments instead of @SuppressWarnings
annotations. But according to the documentation, @SuppressWarnings
annotations are respected by the lint
task.