0

When I use a method that is available in my compileSdk 24, but not in my minSdk 21, Android Studio will build my app without warnings. However When I run the app on a Lollipop (SDK 21) device, it crashes!

See

java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;) exception in sorting arraylist android

for and example.

Can I configure Android Studio to show warnings while building the app?

Mohammed Atif
  • 4,383
  • 7
  • 28
  • 57
Nino van Hooff
  • 3,677
  • 1
  • 36
  • 52
  • Android Studio does warn you when you use deprecated or unsupported methods during development. You can get the list of warnings while building using [Stack Trace](https://stackoverflow.com/questions/21674091/how-to-add-stacktrace-or-debug-option-when-building-android-studio-project) option – Mohammed Atif Jun 20 '17 at 09:04

2 Answers2

0

You should mark "Usages of API which isn't available at the configured language level" checking as error in your lint settings. Then you should run Lint check at build time (you can configure it in gradle).

You can also perform manual check using Analyse -> Inspect Code option in AS.

michalsol
  • 752
  • 8
  • 29
0

Analyze > Inspect Code

This should analyze your project and let you know if there are any compatibility issues.

Marjorie Pickard
  • 109
  • 1
  • 2
  • 10