summaryrefslogtreecommitdiffstats
path: root/docs/html/guide/topics/manifest/uses-sdk-element.jd
blob: 61f03b98b6827994c66690f4aec8f9216b93ca8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
page.title=<uses-sdk>
parent.title=The AndroidManifest.xml File
parent.link=manifest-intro.html
@jd:body


<div id="qv-wrapper">
<div id="qv">

<h2>In this document</h2>
<ol>
  <li><a href="#ApiLevels">What is API Level?</a></li>
  <li><a href="#uses">Uses of API Level in Android</a></li>
  <li><a href="#considerations">Development Considerations</a>
    <ol>
      <li><a href="#fc">Application forward compatibility</a></li>
      <li><a href="#bc">Application backward compatibility</a></li>
      <li><a href="#platform">Selecting a platform version and API Level</a></li>
      <li><a href="#apilevel">Declaring a minimum API Level</a></li>
      <li><a href="#testing">Testing against higher API Levels</a></li>
    </ol>
  </li>
  <li><a href="#provisional">Using a Provisional API Level</a></li>
  <li><a href="#filtering">Filtering the Reference Documentation by API Level</a></li>
</ol>
</div>
</div>

<dl class="xml">
<dt>syntax:</dt>
<dd><pre>
&lt;uses-sdk android:<a href="#min">minSdkVersion</a>="<i>integer</i>" 
          android:<a href="#target">targetSdkVersion</a>="<i>integer</i>"
          android:<a href="#max">maxSdkVersion</a>="<i>integer</i>" /&gt;</pre></dd>

<dt>contained in:</dt>
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>

<dt>description:</dt>
<dd>Lets you express an application's compatibility with one or more versions of the Android platform,
by means of an API Level integer. The API Level expressed by an application will be compared to the
API Level of a given Android system, which may vary among different Android devices.
</p>

<p>Despite its name, this element is used to specify the API Level, <em>not</em>
the version number of the SDK (software development kit) or Android platform. 
The API Level is always a single integer. You cannot derive the API Level from
its associated Android version number (for example, it is not the same as the
major version or the sum of the major and minor versions).</p>

<p>Also read the document about
<a href="{@docRoot}tools/publishing/versioning.html">Versioning Your Applications</a>.
</p></dd> 

 <div class="sidebox-wrapper" xstyle="margin-bottom:2em;margin-top:.5em;width:90%;"> 
  <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png"> 
  <div id="qv-sub-rule"> 
    <img src="{@docRoot}assets/images/icon_play.png" style="float:left;margin:0;padding:0;"> 
    <p style="color:#669999;padding-top:1em;">Google Play and &lt;uses-sdk&gt; attributes</p> 
    <p style="padding-top:1em;">Google Play filters the applications that are visible to users, so
that users can only see and download applications that are compatible with their
devices. One of the ways it filters applications is by Android
version-compatibility. To do this, Google Play checks the <code>&lt;uses-sdk&gt;</code>
attributes in each application's manifest to establish its version-compatibility
range, then shows or hides the application based on a comparison with the API
Level of the user's Android system version. For more information, see <a
href="{@docRoot}guide/google/play/filters.html">Filters on Google Play</a>.</p>
  </div>
</div>

<dt>attributes:</dt>

<dd>
<dl class="attr">
  <dt><a name="min"></a>{@code android:minSdkVersion}</dt>
  <dd>An integer designating the minimum API Level required
  for the application to run. The Android system will prevent the user from installing
  the application if the system's API Level is lower than the value specified in
  this attribute. You should always declare this attribute.

  <p class="caution"><strong>Caution:</strong> If you do not declare this
  attribute, the system assumes a default value of "1", which indicates that your
  application is compatible with all versions of Android. If your application is
  <em>not</em> compatible with all versions (for instance, it uses APIs introduced
  in API Level 3) and you have not declared the proper <code>minSdkVersion</code>,
  then when installed on a system with an API Level less than 3, the application
  will crash during runtime when attempting to access the unavailable APIs. For
  this reason, be certain to declare the appropriate API Level in the
  <code>minSdkVersion</code> attribute.</p>
  </dd>

  <dt><a name="target"></a>{@code android:targetSdkVersion}</dt>
  <dd>An integer designating the API Level that the application targets. If not set, the default
value equals that given to {@code minSdkVersion}.

  <p>This attribute informs the system that you have tested against the target version and the
system should not enable any compatibility behaviors to maintain your app's forward-compatibility
with the target version. The application is still able to run on older versions (down to {@code
minSdkVersion}).</p>

  <p>As Android evolves with each new version, some behaviors and even appearances might change.
However, if the API level of the platform is higher than the version declared by your app's {@code
targetSdkVersion}, the system may enable compatibility behaviors to ensure that your app
continues to work the way you expect. You can disable such compatibility
behaviors by specifying {@code targetSdkVersion} to match the API
level of the platform on which it's running. For example, setting this value to "11" or higher
allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or
higher and also disables <a href="{@docRoot}guide/practices/screen-compat-mode.html">screen
compatibility mode</a> when running on larger screens (because support for API level 11 implicitly
supports larger screens).</p>

  <p>There are many compatibility behaviors that the system may enable based on the value you set
for this attribute. Several of these behaviors are described by the corresponding platform versions
in the {@link android.os.Build.VERSION_CODES} reference.</p>

  <p>To maintain your application along with each Android release, you should increase
the value of this attribute to match the latest API level, then thoroughly test your application on
the corresponding platform version.</p>

  <p>Introduced in: API Level 4</p>
  </dd>

  <dt><a name="max"></a>{@code android:maxSdkVersion}</dt>
  <dd>An integer designating the maximum API Level on which the application is 
  designed to run. 

  <p>In Android 1.5, 1.6, 2.0, and 2.0.1, the system checks the value of this
  attribute when installing an application and when re-validating the application
  after a system update. In either case, if the application's
  <code>maxSdkVersion</code> attribute is lower than the API Level used by
  the system itself, then the system will not allow the application to be
  installed. In the case of re-validation after system update, this effectively
  removes your application from the device.

  <p>To illustrate how this attribute can affect your application after system
  updates, consider the following example: </p>

  <p>An application declaring <code>maxSdkVersion="5"</code> in its
  manifest is published on Google Play. A user whose device is running Android
  1.6 (API Level 4) downloads and installs the app. After a few weeks, the user
  receives an over-the-air system update to Android 2.0 (API Level 5). After the
  update is installed, the system checks the application's
  <code>maxSdkVersion</code> and successfully re-validates it. The
  application functions as normal. However, some time later, the device receives
  another system update, this time to Android 2.0.1 (API Level 6). After the
  update, the system can no longer re-validate the application because the system's
  own API Level (6) is now higher than the maximum supported by the application
  (5). The system prevents the application from being visible to the user, in
  effect removing it from the device.</p>

  <p class="warning"><strong>Warning:</strong> Declaring this attribute is not
  recommended. First, there is no need to set the attribute as means of blocking
  deployment of your application onto new versions of the Android platform as they
  are released. By design, new versions of the platform are fully
  backward-compatible. Your application should work properly on new versions,
  provided it uses only standard APIs and follows development best practices.
  Second, note that in some cases, declaring the attribute can <strong>result in
  your application being removed from users' devices after a system
  update</strong> to a higher API Level. Most devices on which your application
  is likely to be installed will receive periodic system updates over the air, so
  you should consider their effect on your application before setting this
  attribute.</p>

  <p style="margin-bottom:1em;">Introduced in: API Level 4</p>

  <div class="special">Future versions of Android (beyond Android 2.0.1) will no
longer check or enforce the <code>maxSdkVersion</code> attribute during
installation or re-validation. Google Play will continue to use the attribute
as a filter, however, when presenting users with applications available for
download. </div>
  </dd>
  

</dl></dd>

<!-- ##api level indication## -->
<dt>introduced in:</dt>
<dd>API Level 1</dd>

</dl>





<!--- CONTENT FROM OLD API LEVEL DOC ---->




<h2 id="ApiLevels">What is API Level?</h2>

<p>API Level is an integer value that uniquely identifies the framework API
revision offered by a version of the Android platform.</p>

<p>The Android platform provides a framework API that applications can use to
interact with the underlying Android system. The framework API consists of:</p>

<ul>
<li>A core set of packages and classes</li>
<li>A set of XML elements and attributes for declaring a manifest file</li>
<li>A set of XML elements and attributes for declaring and accessing resources</li>
<li>A set of Intents</li>
<li>A set of permissions that applications can request, as well as permission
enforcements included in the system</li>
</ul>

<p>Each successive version of the Android platform can include updates to the
Android application framework API that it delivers. </p>

<p>Updates to the framework API are designed so that the new API remains
compatible with earlier versions of the API. That is, most changes in the API
are additive and introduce new or replacement functionality. As parts of the API
are upgraded, the older replaced parts are deprecated but are not removed, so
that existing applications can still use them. In a very small number of cases,
parts of the API may be modified or removed, although typically such changes are
only needed to ensure API robustness and application or system security. All
other API parts from earlier revisions are carried forward without
modification.</p>

<p>The framework API that an Android platform delivers is specified using an
integer identifier called "API Level". Each Android platform version supports
exactly one API Level, although support is implicit for all earlier API Levels
(down to API Level 1). The initial release of the Android platform provided 
API Level 1 and subsequent releases have incremented the API Level.</p>

<p>The following table specifies the API Level supported by each version of the
Android platform.</p>

<table>
  <tr><th>Platform Version</th><th>API Level</th><th>VERSION_CODE</th><th>Notes</th></tr>
 
    <tr><td><a href="{@docRoot}about/versions/android-4.1.html">Android 4.1, 4.1.1</a></td>
    <td><a href="{@docRoot}sdk/api_diff/16/changes.html" title="Diff Report">16</a></td>
    <td>{@link android.os.Build.VERSION_CODES#JELLY_BEAN}</td>
    <td><a href="{@docRoot}about/versions/jelly-bean.html">Platform
Highlights</a></td></tr>

    <tr><td><a href="{@docRoot}about/versions/android-4.0.3.html">Android 4.0.3, 4.0.4</a></td>
    <td><a href="{@docRoot}sdk/api_diff/15/changes.html" title="Diff Report">15</a></td>
    <td>{@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1}</td>
    <td rowspan="2"><a href="{@docRoot}about/versions/android-4.0-highlights.html">Platform
Highlights</a></td></tr>

    <tr><td><a href="{@docRoot}about/versions/android-4.0.html">Android 4.0, 4.0.1, 4.0.2</a></td>
    <td><a href="{@docRoot}sdk/api_diff/14/changes.html" title="Diff Report">14</a></td>
    <td>{@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}</td>
    </tr>
  
    <tr><td><a href="{@docRoot}about/versions/android-3.2.html">Android 3.2</a></td>
    <td><a href="{@docRoot}sdk/api_diff/13/changes.html" title="Diff Report">13</a></td>
    <td>{@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}</td>
    <td><!-- <a href="{@docRoot}about/versions/android-3.2-highlights.html">Platform
Highlights</a>--></td></tr>
  
  <tr><td><a href="{@docRoot}about/versions/android-3.1.html">Android 3.1.x</a></td>
    <td><a href="{@docRoot}sdk/api_diff/12/changes.html" title="Diff Report">12</a></td>
    <td>{@link android.os.Build.VERSION_CODES#HONEYCOMB_MR1}</td>
    <td><a href="{@docRoot}about/versions/android-3.1-highlights.html">Platform Highlights</a></td></tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-3.0.html">Android 3.0.x</td>
    <td><a href="{@docRoot}sdk/api_diff/11/changes.html" title="Diff Report">11</a></td>
    <td>{@link android.os.Build.VERSION_CODES#HONEYCOMB}</td>
    <td><a href="{@docRoot}about/versions/android-3.0-highlights.html">Platform Highlights</a></td></tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-2.3.3.html">Android 2.3.4<br>Android 2.3.3</td>
    <td><a href="{@docRoot}sdk/api_diff/10/changes.html" title="Diff Report">10</a></td>
    <td>{@link android.os.Build.VERSION_CODES#GINGERBREAD_MR1}</td>
    <td rowspan="2"><a href="{@docRoot}about/versions/android-2.3-highlights.html">Platform
Highlights</a></td></tr>
  
  <tr><td><a href="{@docRoot}about/versions/android-2.3.html">Android 2.3.2<br>Android 2.3.1<br>Android
2.3</td>
    <td><a href="{@docRoot}sdk/api_diff/9/changes.html" title="Diff Report">9</a></td>
    <td>{@link android.os.Build.VERSION_CODES#GINGERBREAD}</td>
    </tr>
  
  <tr><td><a href="{@docRoot}about/versions/android-2.2.html">Android 2.2.x</td>
    <td ><a href="{@docRoot}sdk/api_diff/8/changes.html" title="Diff Report">8</a></td>
    <td>{@link android.os.Build.VERSION_CODES#FROYO}</td>
    <td><a href="{@docRoot}about/versions/android-2.2-highlights.html">Platform Highlights</a></td></tr>
  
  <tr><td><a href="{@docRoot}about/versions/android-2.1.html">Android 2.1.x</td>
    <td><a href="{@docRoot}sdk/api_diff/7/changes.html" title="Diff Report">7</a></td>
    <td>{@link android.os.Build.VERSION_CODES#ECLAIR_MR1}</td>
    <td rowspan="3" ><a href="{@docRoot}about/versions/android-2.0-highlights.html">Platform
Highlights</a></td></tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-2.0.1.html">Android 2.0.1</td>
    <td><a href="{@docRoot}sdk/api_diff/6/changes.html" title="Diff Report">6</a></td>
    <td>{@link android.os.Build.VERSION_CODES#ECLAIR_0_1}</td>
    </tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-2.0.html">Android 2.0</td>
    <td><a href="{@docRoot}sdk/api_diff/5/changes.html" title="Diff Report">5</a></td>
    <td>{@link android.os.Build.VERSION_CODES#ECLAIR}</td>
    </tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-1.6.html">Android 1.6</td>
    <td><a href="{@docRoot}sdk/api_diff/4/changes.html" title="Diff Report">4</a></td>
    <td>{@link android.os.Build.VERSION_CODES#DONUT}</td>
    <td><a href="{@docRoot}about/versions/android-1.6-highlights.html">Platform Highlights</a></td></tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-1.5.html">Android 1.5</td>
    <td><a href="{@docRoot}sdk/api_diff/3/changes.html" title="Diff Report">3</a></td>
    <td>{@link android.os.Build.VERSION_CODES#CUPCAKE}</td>
    <td><a href="{@docRoot}about/versions/android-1.5-highlights.html">Platform Highlights</a></td></tr>
    
  <tr><td><a href="{@docRoot}about/versions/android-1.1.html">Android 1.1</td>
    <td>2</td>
    <td>{@link android.os.Build.VERSION_CODES#BASE_1_1}</td><td></td></tr>
    
  <tr><td>Android 1.0</td>
    <td>1</td>
    <td>{@link android.os.Build.VERSION_CODES#BASE}</td>
    <td></td></tr>
</table>


<h2 id="uses">Uses of API Level in Android</h2>

<p>The API Level identifier serves a key role in ensuring the best possible
experience for users and application developers: 

<ul>
<li>It lets the Android platform describe the maximum framework API revision 
that it supports</li>
<li>It lets applications describe the framework API revision that they
require</li>
<li>It lets the system negotiate the installation of applications on the user's
device, such that version-incompatible applications are not installed.</li>
</ul>

<p>Each Android platform version stores its API Level identifier internally, in
the Android system itself. </p>

<p>Applications can use a manifest element provided by the framework API &mdash;
<code>&lt;uses-sdk&gt;</code> &mdash; to describe the minimum and maximum API
Levels under which they are able to run, as well as the preferred API Level that
they are designed to support. The element offers three key attributes:</p>

<ul>
<li><code>android:minSdkVersion</code> &mdash; Specifies the minimum API Level
on which the application is able to run. The default value is "1".</li>
<li><code>android:targetSdkVersion</code> &mdash; Specifies the API Level
on which the application is designed to run. In some cases, this allows the
application to use manifest elements or behaviors defined in the target
API Level, rather than being restricted to using only those defined 
for the minimum API Level.</li>
<li><code>android:maxSdkVersion</code> &mdash; Specifies the maximum API Level
on which the application is able to run. <strong>Important:</strong> Please read the <a
href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"><code>&lt;uses-sdk&gt;</code></a>
documentation before using this attribute.  </li>
</ul>

<p>For example, to specify the minimum system API Level that an application
requires in order to run, the application would include in its manifest a
<code>&lt;uses-sdk&gt;</code> element with a <code>android:minSdkVersion</code>
attribute. The value of <code>android:minSdkVersion</code> would be the integer
corresponding to the API Level of the earliest version of the Android platform
under which the application can run. </p>

<p>When the user attempts to install an application, or when revalidating an
appplication after a system update, the Android system first checks the
<code>&lt;uses-sdk&gt;</code> attributes in the application's manifest and
compares the values against its own internal API Level. The system allows the
installation to begin only if these conditions are met:</p>

<ul>
<li>If a <code>android:minSdkVersion</code> attribute is declared, its value
must be less than or equal to the system's API Level integer. If not declared,
the system assumes that the application requires API Level 1. </li>
<li>If a <code>android:maxSdkVersion</code> attribute is declared, its value
must be equal to or greater than the system's API Level integer. 
If not declared, the system assumes that the application
has no maximum API Level. Please read the <a
href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"><code>&lt;uses-sdk&gt;</code></a>
documentation for more information about how the system handles this attribute.</li>
</ul>

<p>When declared in an application's manifest, a <code>&lt;uses-sdk&gt;</code>
element might look like this: </p>

<pre>&lt;manifest&gt;
  &lt;uses-sdk android:minSdkVersion="5" /&gt;
  ...
&lt;/manifest&gt;</pre>

<p>The principal reason that an application would declare an API Level in
<code>android:minSdkVersion</code> is to tell the Android system that it is
using APIs that were <em>introduced</em> in the API Level specified. If the
application were to be somehow installed on a platform with a lower API Level,
then it would crash at run-time when it tried to access APIs that don't exist.
The system prevents such an outcome by not allowing the application to be
installed if the lowest API Level it requires is higher than that of the
platform version on the target device.</p>

<p>For example, the {@link android.appwidget} package was introduced with API
Level 3. If an application uses that API, it must declare a
<code>android:minSdkVersion</code> attribute with a value of "3". The
application will then be installable on platforms such as Android 1.5 (API Level
3) and Android 1.6 (API Level 4), but not on the Android 1.1 (API Level 2) and
Android 1.0 platforms (API Level 1).</p>

<p>For more information about how to specify an application's API Level
requirements, see the <a
href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"><code>&lt;uses-sdk&gt;</code></a>
 section of the manifest file documentation.</p>


<h2 id="considerations">Development Considerations</h2>

<p>The sections below provide information related to API level that you should
consider when developing your application.</p>

<h3 id="fc">Application forward compatibility</h3>

<p>Android applications are generally forward-compatible with new versions of
the Android platform.</p>

<p>Because almost all changes to the framework API are additive, an Android
application developed using any given version of the API (as specified by its
API Level) is forward-compatible with later versions of the Android platform and
higher API levels. The application should be able to run on all later versions
of the Android platform, except in isolated cases where the application uses a
part of the API that is later removed for some reason. </p>

<p>Forward compatibility is important because many Android-powered devices
receive over-the-air (OTA) system updates. The user may install your
application and use it successfully, then later receive an OTA update to a new
version of the Android platform. Once the update is installed, your application
will run in a new run-time version of the environment, but one that has the API
and system capabilities that your application depends on. </p>

<p>In some cases, changes <em>below</em> the API, such those in the underlying
system itself, may affect your application when it is run in the new
environment. For that reason it's important for you, as the application
developer, to understand how the application will look and behave in each system
environment. To help you test your application on various versions of the Android
platform, the Android SDK includes multiple platforms that you can download.
Each platform includes a compatible system image that you can run in an AVD, to
test your application. </p>

<h3 id="bc">Application backward compatibility</h3>

<p>Android applications are not necessarily backward compatible with versions of
the Android platform older than the version against which they were compiled.
</p>

<p>Each new version of the Android platform can include new framework APIs, such
as those that give applications access to new platform capabilities or replace
existing API parts. The new APIs are accessible to applications when running on
the new platform and, as mentioned above, also when running on later versions of
the platform, as specified by API Level. Conversely, because earlier versions of
the platform do not include the new APIs, applications that use the new APIs are
unable to run on those platforms.</p>

<p>Although it's unlikely that an Android-powered device would be downgraded to
a previous version of the platform, it's important to realize that there are
likely to be many devices in the field that run earlier versions of the
platform. Even among devices that receive OTA updates, some might lag and
might not receive an update for a significant amount of time. </p>

<h3 id="platform">Selecting a platform version and API Level</h3>

<p>When you are developing your application, you will need to choose
the platform version against which you will compile the application. In
general, you should compile your application against the lowest possible
version of the platform that your application can support. 

<p>You can determine the lowest possible platform version by compiling the
application against successively lower build targets. After you determine the
lowest version, you should create an AVD using the corresponding platform
version (and API Level) and fully test your application. Make sure to declare a
<code>android:minSdkVersion</code> attribute in the application's manifest and
set its value to the API Level of the platform version. </p>

<h3 id="apilevel">Declaring a minimum API Level</h3>

<p>If you build an application that uses APIs or system features introduced in
the latest platform version, you should set the
<code>android:minSdkVersion</code> attribute to the API Level of the latest
platform version. This ensures that users will only be able to install your
application if their devices are running a compatible version of the Android
platform. In turn, this ensures that your application can function properly on
their devices. </p>

<p>If your application uses APIs introduced in the latest platform version but
does <em>not</em> declare a <code>android:minSdkVersion</code> attribute, then
it will run properly on devices running the latest version of the platform, but
<em>not</em> on devices running earlier versions of the platform. In the latter
case, the application will crash at runtime when it tries to use APIs that don't
exist on the earlier versions.</p>

<h3 id="testing">Testing against higher API Levels</h3>

<p>After compiling your application, you should make sure to test it on the
platform specified in the application's <code>android:minSdkVersion</code>
attribute. To do so, create an AVD that uses the platform version required by
your application. Additionally, to ensure forward-compatibility, you should run
and test the application on all platforms that use a higher API Level than that
used by your application. </p>

<p>The Android SDK includes multiple platform versions that you can use,
including the latest version, and provides an updater tool that you can use to
download other platform versions as necessary. </p>

<p>To access the updater, use the <code>android</code> command-line tool,
located in the &lt;sdk&gt;/tools directory. You can launch the SDK updater by
executing <code>android sdk</code>. You can
also simply double-click the android.bat (Windows) or android (OS X/Linux) file.
In ADT, you can also access the updater by selecting 
<strong>Window</strong>&nbsp;>&nbsp;<strong>Android SDK
Manager</strong>.</p>

<p>To run your application against different platform versions in the emulator,
create an AVD for each platform version that you want to test. For more
information about AVDs, see <a
href="{@docRoot}tools/devices/index.html">Creating and Managing Virtual Devices</a>. If
you are using a physical device for testing, ensure that you know the API Level
of the Android platform it runs. See the table at the top of this document for
a list of platform versions and their API Levels. </p>

<h2 id="provisional">Using a Provisional API Level</h2>

<p>In some cases, an "Early Look" Android SDK platform may be available. To let
you begin developing on the platform although the APIs may not be final, the
platform's API Level integer will not be specified. You must instead use the
platform's <em>provisional API Level</em> in your application manifest, in order
to build applications against the platform. A provisional API Level is not an
integer, but a string matching the codename of the unreleased platform version.
The provisional API Level will be specified in the release notes for the Early
Look SDK release notes and is case-sensitive.</p>

<p>The use of a provisional API Level is designed to protect developers and
device users from inadvertently publishing or installing applications based on
the Early Look framework API, which may not run properly on actual devices
running the final system image.</p>

<p>The provisional API Level will only be valid while using the Early Look SDK
and can only be used to run applications in the emulator. An application using
the provisional API Level can never be installed on an Android device. At the
final release of the platform, you must replace any instances of the provisional
API Level in your application manifest with the final platform's actual API
Level integer.</p>


<h2 id="filtering">Filtering the Reference Documentation by API Level</h2>

<p>Reference documentation pages on the Android Developers site offer a "Filter
by API Level" control in the top-right area of each page. You can use the 
control to show documentation only for parts of the API that are actually 
accessible to your application, based on the API Level that it specifies in 
the <code>android:minSdkVersion</code> attribute of its manifest file. </p>

<p>To use filtering, select the checkbox to enable filtering, just below the
page search box. Then set the "Filter by API Level" control to the same API
Level as specified by your application. Notice that APIs introduced in a later
API Level are then grayed out and their content is masked, since they would not
be accessible to your application. </p>

<p>Filtering by API Level in the documentation does not provide a view
of what is new or introduced in each API Level &mdash; it simply provides a way
to view the entire API associated with a given API Level, while excluding API
elements introduced in later API Levels.</p>

<p>If you decide that you don't want to filter the API documentation, just
disable the feature using the checkbox. By default, API Level filtering is
disabled, so that you can view the full framework API, regardless of API Level.
</p>

<p>Also note that the reference documentation for individual API elements
specifies the API Level at which each element was introduced. The API Level 
for packages and classes is specified as "Since &lt;api level&gt;" at the 
top-right corner of the content area on each documentation page. The API Level 
for class members is specified in their detailed description headers, 
at the right margin. </p>