Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I don't Understand Call or Class Requires API Level 3

I'm doing some Android work in IntelliJ 13. I've created an Android test application so I can start writing unit tests. IntelliJ is reporting an error I haven't seen before and this error does not prevent the code from working:

Call requires API level 3 (current min is 1)

It will also have an error at the class level that is:

Class requires API level 3 (current min is 1)

And sometimes it will say level 11.

enter image description here

like image 523
Gregg Avatar asked Mar 22 '23 07:03

Gregg


2 Answers

You need to set min SDK version in AndroidManifest like

<uses-sdk android:targetSdkVersion="18" android:minSdkVersion="11"/>
like image 84
Josef Raška Avatar answered Apr 02 '23 06:04

Josef Raška


As Josef said, you need to increase the minimum SDK version specified in your AndroidManifest.xml file - this is the minimum Android API version you support. The error messages you're getting ("requires API level 11") mean that the method or class you're trying to use was only introduced in API 11. There are ways around this - specifically, the support library is an official back-port of many newer features, included in your SDK.

Have a look at the Android Dashboards to choose a minimum API level (and hence your device/userbase coverage) - typically 8 or 10, if you plan on supporting "older" devices (Android 2.2 and 2.3 devices), and 14 or 15 if you plan on supporting only newer (Android 4.x) devices.

Generally you'd specify your targetSdkVersion to be the latest version of Android - at the moment, this is 19. You need your SDK up-to-date, though.

The developer documentation has an in-depth explanation of what these things mean - I'd recommend having a read.

like image 41
Adam S Avatar answered Apr 02 '23 06:04

Adam S