0

In Android Studio it is possible to select a "minimum API level" that is required to run the developed application. If I use some higher level API, an error is displayed and the code will not compile. This is as desired.

But can I somehow configure Android Studio that it already doesn't show suggestion for APIs that are not supported by my targeted API level?

For Example, if I develop for Android Marshmallow (6.0, API level 23) I want to configure Android Studio so that it does not suggest classes, methods etc. that are only available in Android Oreo (8.0, API level 26).

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
Till F.
  • 189
  • 1
  • 9
  • not really, since there is no such thing as `maxApiLevel` which would address your issue. – Shark Aug 31 '18 at 11:49
  • More importantly, you will need to use those newer classes from time to time, just only on those newer devices. – CommonsWare Aug 31 '18 at 11:57
  • If I would only use the latest API I could target at most 1% of android users. This doesn't make any sense, so it is inevitable to use deprecated APIs. It just would be great if Android Studio would support this a little bit more. – Till F. Sep 03 '18 at 09:24

1 Answers1

0

You already get lint warnings when trying to use higher API methods, which should be enough.

It would be counter-intuitive to outright prevent calling them, since a lot of them provide native implementation of functionality that has to be otherwise back-ported (with performance hit) for older devices.

Pawel
  • 15,548
  • 3
  • 36
  • 36
  • 1
    Well, the use case is the following: I want to make an app compatible with an old Android version. I have never developed for this version before, so I don't now the APIs that were available at that time. If I could "narrow down" the code completion it would save me a lot of time, because in many cases the "old way to do things" becomes obvious just by looking at suggested methods. – Till F. Aug 31 '18 at 12:09