Android minSDKVersion and targetSDKVerion

Asked

Viewed 4,309 times

2

What’s the difference between minSDKVersion and targetSDKVerion?

Androidmanifest.xml:

 <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

1 answer

7


Jorge,

minSdkVersion indicates which minimum API is required to run the application. In your case, minSdkVersion="14", indicates that it will not be possible to run the application if the user has the API before 14 (Android 4.0.0).

targetSdkVersion indicates to which API your application has been developed, when no value is assigned, the value of the minSdkVersion is assumed.

Excerpt from the documentation on the minSdkVersion:

Caution: If you do not declare this attribute, the system assumes a value "1" standard, which indicates that your application is compatible with all versions of Android. If your app is not compatible with all the versions (for example, it uses Apis introduced in the Level 3 API) and you did not declare the minSdkVersion then when installed in a system with an API level below 3, the application will fail at runtime when trying to access the unavailable Apis. By this reason, it is certain to declare the appropriate API level in the attribute minSdkVersion.

And it is still possible to indicate the maxSdkVersion, which means the maximum API to run your application.

Excerpt from the documentation on the minSdkVersion:

Warning: Declaring this attribute is not recommended. First, there is no need to define the attribute as a means of blocking the installation of its application in new versions of the Android platform. By the project, the new versions of the platform are fully compatible with previous versions. Your application should work properly in a new version, as long as you only use Apis standard and follow best development practices. Second place, note that in some cases declaring the attribute may result in its application that is being removed users' devices after a system upgrade to a higher API level. A most devices on which your request is likely to be installed will receive periodic system updates, then you should consider its effect on your app before to define this attribute.

There is a very detailed explanation in this documentation: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

  • 1

    So like with me and target the question. There will be no compatibility issues if I run on a device with API 14, since I developed for API 19?

  • Exactly. No problem, but trying to run on API 13 will not work.

  • And if I put min=13 and target=19 there will be no compatibility problems of the app? It seems to me a little strange that API 13 has nothing to do with 19. And if I am developing for 19 it is not logical to have no problems when installing on a device with API 13.

  • Jorge, I changed the original answer.

  • 2

    Very good. Just one more question. The ideal will be by min and target equal?

  • Ideally set minSdkVersion with the highest API number used in your app.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.