0

I'm trying to suppress this warning when I build a sample app provided on Android Github :

Note: app/src/main/java/com/example/android/testing/unittesting/BasicSample/MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

What I've tried so far is just everything proposed in Stackoverflow, including :

gradle clean build -x lint

or in MainActivity.java :

@SuppressWarnings("all")
@SuppressLint("all")
public class MainActivity extends Activity {

What else can I try ?

Tristan
  • 8,733
  • 7
  • 48
  • 96
  • 2
    Don't use deprecated APIs? – Seelenvirtuose Jun 28 '21 at 11:10
  • 1
    It is generally a bad idea to ignore warnings. It is a worse idea to configure your build or source code to suppress the warnings. A deprecation warning is telling you that your code is liable to break in the future if you haven't stopped using the deprecated thing. You should not be hiding that ... – Stephen C Jun 28 '21 at 11:18
  • If the sample app you are playing with has deprecation warnings, you should probably look for something that isn't out of date. Certainly, you don't want to copy the out-of-date usages into >your< code. – Stephen C Jun 28 '21 at 11:19
  • All these comments are obvious and not relevant for my question. – Tristan Jun 28 '21 at 12:16

1 Answers1

1

Preferences >> Editor >> Inspections >> Java (or Kotlin) >> Code maturity >> Uncheck Deprecated API usage

Ignore Deprecated Warning

David Lee
  • 665
  • 7
  • 20
  • Ok, thanks, now how does it translate into a gradle command line (I'm not using Android Studio) ? – Tristan Jun 28 '21 at 12:17
  • All relevant commands can be found here: https://stackoverflow.com/a/34171304/9246764 – David Lee Jun 28 '21 at 12:22
  • yes I know this article, there are many commands, but none of them is working for my little example. I'm providing full code, have u tried your UI method or any of these commands ? Does something work for you ? – Tristan Jun 28 '21 at 12:44