• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=<uses-sdk>
2parent.title=The AndroidManifest.xml File
3parent.link=manifest-intro.html
4@jd:body
5
6<dl class="xml">
7<dt>syntax:</dt>
8<dd><pre>
9&lt;uses-sdk android:<a href="#min">minSdkVersion</a>="<i>integer</i>"
10          android:<a href="#target">targetSdkVersion</a>="<i>integer</i>"
11          android:<a href="#max">maxSdkVersion</a>="<i>integer</i>" /&gt;</pre></dd>
12
13<dt>contained in:</dt>
14<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
15
16<dt>description:</dt>
17<dd>Lets you express an application's compatibility with one or more versions of the Android platform,
18by means of an API Level integer. The API Level expressed by an application will be compared to the
19API Level of a given Android system, which may vary among different Android devices.
20</p>
21
22<p>Despite its name, this element is used to specify the API Level, <em>not</em>
23the version number of the SDK (software development kit) or Android platform.
24The API Level is always a single integer. You cannot derive the API Level from
25its associated Android version number (for example, it is not the same as the
26major version or the sum of the major and minor versions).</p>
27
28<p>For more information, read about
29<a href="{@docRoot}guide/appendix/api-levels.html">Android API Levels</a> and
30<a href="{@docRoot}guide/publishing/versioning.html">Versioning Your Applications</a>.
31</p></dd>
32
33 <div class="sidebox-wrapper" xstyle="margin-bottom:2em;margin-top:.5em;width:90%;">
34  <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png">
35  <div id="qv-sub-rule">
36    <img src="{@docRoot}assets/images/icon_market.jpg" style="float:left;margin:0;padding:0;">
37    <p style="color:#669999;">Android Market and &lt;uses-sdk&gt; attributes</p>
38    <p>Android Market filters the applications that are visible to users, so
39that users can only see and download applications that are compatible with their
40devices. One of the ways Market filters applications is by Android
41version-compatibility. To do this, Market checks the <code>&lt;uses-sdk&gt;</code>
42attributes in each application's manifest to establish its version-compatibility
43range, then shows or hides the application based on a comparison with the API
44Level of the user's Android system version. For more information, see <a
45href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>.</p>
46  </div>
47</div>
48
49<dt>attributes:</dt>
50
51<dd>
52<dl class="attr">
53  <dt><a name="min"></a>{@code android:minSdkVersion}</dt>
54  <dd>An integer designating the minimum API Level required
55  for the application to run. The Android system will prevent the user from installing
56  the application if the system's API Level is lower than the value specified in
57  this attribute. You should always declare this attribute.
58
59  <p class="caution"><strong>Caution:</strong> If you do not declare this
60  attribute, the system assumes a default value of "1", which indicates that your
61  application is compatible with all versions of Android. If your application is
62  <em>not</em> compatible with all versions (for instance, it uses APIs introduced
63  in API Level 3) and you have not declared the proper <code>android:minSdkVersion</code>,
64  then when installed on a system with an API Level less than 3, the application
65  will crash during runtime when attempting to access the unavailable APIs. For
66  this reason, be certain to declare the appropriate API Level in the
67  <code>minSdkVersion</code> attribute.</p>
68  </dd>
69
70  <dt><a name="target"></a>{@code android:targetSdkVersion}</dt>
71  <dd>An integer designating the API Level that the application is targetting.
72
73  <p>With this attribute set, the application says that it is able to run on
74  older versions (down to {@code minSdkVersion}), but was explicitly tested to
75  work with the version specified here. Specifying this target version allows the
76  platform to disable compatibility settings that are not required for the target
77  version (which may otherwise be turned on in order to maintain
78  forward-compatibility) or enable newer features that are not available to older
79  applications. This does not mean that you can program different features for
80  different versions of the platform&mdash;it simply informs the platform that you
81  have tested against the target version and the platform should not perform any
82  extra work to maintain forward-compatibility with the target version.</p>
83
84  <p>Introduced in: API Level 4</p>
85  </dd>
86
87  <dt><a name="max"></a>{@code android:maxSdkVersion}</dt>
88  <dd>An integer designating the maximum API Level on which the application is
89  designed to run.
90
91  <p>In Android 1.5, 1.6, 2.0, and 2.0.1, the system checks the value of this
92  attribute when installing an application and when revalidating the application
93  after a system update. In either case, if the application's
94  <code>android:maxSdkVersion</code> attribute is lower than the API Level used by
95  the system itself, then the system will not allow the application to be
96  installed. In the case of revalidation after system update, this effectively
97  removes your application from the device.
98
99  <p>To illustrate how this attribute can affect your application after system
100  updates, consider the following example: </p>
101
102  <p>An application declaring <code>android:maxSdkVersion="5"</code> in its
103  manifest is published on Android Market. A user whose device is running Android
104  1.6 (API Level 4) downloads and installs the app. After a few weeks, the user
105  receives an over-the-air system update to Android 2.0 (API Level 5). After the
106  update is installed, the system checks the application's
107  <code>android:maxSdkVersion</code> and successfully revalidates it. The
108  application functions as normal. However, some time later, the device receives
109  another system update, this time to Android 2.0.1 (API Level 6). After the
110  update, the system can no longer revalidate the application because the system's
111  own API Level (6) is now higher than the maximum supported by the application
112  (5). The system prevents the application from being visible to the user, in
113  effect removing it from the device.</p>
114
115  <p class="warning"><strong>Warning:</strong> Declaring this attribute is not
116  recommended. First, there is no need to set the attribute as means of blocking
117  deployment of your application onto new versions of the Android platform as they
118  are released. By design, new versions of the platform are fully
119  backward-compatible. Your application should work properly on new versions,
120  provided it uses only standard APIs and follows development best practices.
121  Second, note that in some cases, declaring the attribute can <strong>result in
122  your application being removed from users' devices after a system
123  update</strong> to a higher API Level. Most devices on which your appplication
124  is likely to be installed will receive periodic system updates over the air, so
125  you should consider their effect on your application before setting this
126  attribute.</p>
127
128  <p style="margin-bottom:1em;">Introduced in: API Level 4</p>
129
130  <div class="special">Future versions of Android (beyond Android 2.0.1) will no
131longer check or enforce the <code>android:maxSdkVersion</code> attribute during
132installation or revalidation. Android Market will continue to use the attribute
133as a filter, however, when presenting users with applications available for
134download. </div>
135  </dd>
136
137
138</dl></dd>
139
140<!-- ##api level indication## -->
141<dt>introduced in:</dt>
142<dd>API Level 1</dd>
143
144</dl>
145