0

In a project with API 16 compatibility I've been using vector drawables with ContextCompat.getDrawable() which is of course incorrect and crashes in old devices, needing to be replaced by AppCompatResources instead. I have removed all method calls, but how can I prevent them from appearing again in case of distraction?

Note that the API is not deprecated, can a good API be somehow flagged as error in a project? The minSdkVersion is set to 16 and targetSdkVersion and compileSdkVersion to 27, the ContextCompat.getDrawable API is for all purposes available on any API level, but fails when used with vector drawables, so I want to prevent during compilation its usage in favor of AppCompatResources.

Grzegorz Adam Hankiewicz
  • 7,349
  • 1
  • 36
  • 78

1 Answers1

0

Usually, Android Studio indicates when you're trying to use a method whose minimum API level is higher than your minimum project API level. I don't think is a good idea try to flag as error some API, as you would have to mark or delete the whole android.support.v4 API entry from your Gradle file (it could be an option if you're not interested in keeping it). Just make sure you use the app compat v7 one when you import the package and you're done :)