Вопрос

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

Это было полезно?

Решение

You need to set min SDK version in AndroidManifest like

<uses-sdk android:targetSdkVersion="18" android:minSdkVersion="11"/>

Другие советы

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.

If after making above changes you still have an issue, please use File > Invalidate Caches / Restart. Here it explains what it does. In case you don't read that, summary warning:

Cleaning system caches also results in clearing the local history. To avoid losing data, check in the changes to your version control system before invalidating caches.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top