Search code examples
androidcompatibilitylibrariesnosuchmethoderror

How to setup android libraries to support different android versions


I have developed an application for Android in Kotlin. I was assuming that Android studio is taking care of the compatibility of the used libraries and the code once I setup the minimum targetted Android version.

I am getting responses that the app is crashing with noSuchMethodError, which is linked to a listview's .getView() methode.

I am running the app on Android 8, but these errors are reported on Android 6 and 7 randomly.

I was reading different articles about this failure and I am having the feeling that i might need to setup the libraries setting differently in Studio.


Solution

  • In your build.gradle you can specify a minSdk and a targetSdk, while the targetSdk specifies as the name says the target audience and is in general the newest version e.G. 29, your minSdk takes care of your minimum supported version.

    So if you have minSDK 19, Android Studio will show Warnings in your code whenever a method or class is not compatible with devices running sdk 19.

    Anyway this might not solve your "noSuchMethodError".