Android sdk version and API level

确定app的系统API level,在mainfest中设置minSdkVersiontargetSdkVersion;对app进行版本控制,在mainfest中设置versionCodeversionName

Supporting Different Platform Versions

Tip: In order to provide the best features and functionality across several Android versions, you should use the Android Support Library in your app, which allows you to use several recent platform APIs on older versions.

To allow your app to take advantage of these changes and ensure that your app fits the style of each user‘s device, you should set thetargetSdkVersion value to match the latest Android version available.

参考文献:What API level should I target?

Tips:

  • Set android:minSdkVersion to the minimum API level you support.
  • Set android:targetSdkVersion to the highest API level you tested your app on.
  • Do not use android:maxSdkVersion.
  • Set your build target to whatever (I recommend the same as your android:targetSdkVersion), it does not affect the final APK.
  • Wrap calls to new APIs in an if where you check the API level.
  • Test your apps!

<uses-sdk>

<mainfest>

<uses-sdk android:minSdkVersion="integer"          android:targetSdkVersion="integer"          android:maxSdkVersion="integer" />

integer -- the value of API level

minSdkVersion(Required): the minimum API level. If not set, the default API level is "1".

If the application were to be somehow installed on a platform with a lower API Level(less than the minSdkVersion value), then it would crash at run-time when it tried to access APIs that don‘t exist. And the app would not be installed if this value is higher than that of hte platform version on the target device.

targetSdkVersion(Recommended): The API level the application is designed to run and it allows the app to use manifest elements or behaviors defined in the target API level. If not set, the integer value equals to minSdkVersion and only the minimum API level is used.

maxSdkVersion(Not recommended): If the API level is greater than this value, the app will not be installed. And after a system update, its value must be equal or greater than the system‘s API Level interger.

Check System Version at Runtime

private void setUpActionBar() {    // Make sure we‘re running on Honeycomb or higher to use ActionBar APIs    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {        ActionBar actionBar = getActionBar();        actionBar.setDisplayHomeAsUpEnabled(true);    }}

Note:还可以在XML中使用新版本的attributes,如果版本不支持,低版本的Android仅仅ignore某个attribute。

API Level

某个版本的 Android platform 提供的 framework API revision, through framework API app can interact with underlying Android system.

The framework API consists of:

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

Android applications are generally forward-compatible with new versions of the Android platform.

Filtering the Reference Documentation by API Level

By default, API Level filtering is disabled, so that you can view the full framework API, regardless of API Level.

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.

Filtering by API Level in the documentation does not provide a view of what is new or introduced in each API Level — 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.

Versioning Your Applications-- Android APP 版本控制

android:versionCode — An integer value that represents the version of the application code, relative to other versions. Applications and publishing services should not display this version value to users.

android:versionName — A string value(<major>.<minor>.<point>) that represents the release version of the application code, as it should be shown to users. Publishing services may extract

the android:versionName value for display to users.

eg.

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"      package="com.example.package.name"      android:versionCode="2"      android:versionName="1.1">    <application android:icon="@drawable/icon" android:label="@string/app_name">        ...    </application></manifest>
时间: 2024-08-01 10:42:19

Android sdk version and API level的相关文章

Android SDK版本号与API Level 的对应关系-转

Android SDK版本号 与 API Level 对应关系 http://developer.android.com/guide/appendix/api-levels.html Android SDK版本号 与 API Level 对应关系如下表: 平台版本 API 级别 VERSION_CODE 备注 Android 7.0 24 N 平台亮点 Android 6.0 23 M 平台亮点 Android 5.1 22 LOLLIPOP_MR1 平台亮点 Android 5.0 21 LO

Android Platform Version 和 API Level对照

Platform Version API Level VERSION_CODE Notes Android 5.1 22 LOLLIPOP_MR1 Platform Highlights Android 5.0 21 LOLLIPOP Platform Highlights Android 4.4W 20 KITKAT_WATCH Platform Highlights Android 4.4 19 KITKAT Platform Highlights Android 4.3 18 JELLY_

修改Android Studio默认的API Level(SDK版本)

原文:修改Android Studio默认的API Level(SDK版本) Android Studio(2.1.2)新建工程的时候只会让你选择最低支持的SDK版本,默认的目标编译SDK版本会以系统当前SDK中最新SDK platform作为目标的API Level.但是很多时候我们并不需要最新的SDK版本,如何修改呢? 方法是:修改工程目录中的Gradle Scripts->build.gradle(Module:app)中的相关行,具体见下图: 当然也可以图形化操作,右键工程目录选择"

Android SDK Version 对应的 rom 版本

Platform Version API Level VERSION_CODE Notes Android 4.4 19 KITKAT Platform Highlights Android 4.3 18 JELLY_BEAN_MR2 Platform Highlights Android 4.2, 4.2.2 17 JELLY_BEAN_MR1 Platform Highlights Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights An

【Android】Field requires API level 4 (current min is 1): android.os.Build.VERSION#SDK_INT

刚遇到了这个问题: Field requires API level 4 (current min is 1): android.os.Build.VERSION#SDK_INT 解决方法: 修改 AndroidManifest.xml 中的 uses-sdk 标签,例如: <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14" /> 参考:Android程序出现错误“Field

Android各版本的SDK Platforms和API Level

Name   API Level Revision Highlights Time Android 8.1 Oreo 奥利奥 27 1   2017.10 Android 8.0 Oreo 奥利奥 26 2   2017.3 Android 7.1.1 Nougat 25 1   2016.12 Android 7.0 Nougat 牛轧糖 24 2   2016.8 Android 6.0 Marshmallow 棉花糖 23 3 动态权限 2015.5 Android 5.1 Lollipo

Android系统版本与API Level对照表

Platform Version API Level VERSION_CODE Notes Android 4.2 17 JELLY_BEAN_MR1   Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH Andr

android sdk 版本与api对应

实际上可以在Android SDK Manager工具中查看,但可能不全 android 6.0 API 23 android 5.1.1 API 22 android 5.0.1 API 21 android 4.4W.2 API 20 android 4.4.2 API 19 android 4.3.1 API 18 android 4.2.2 API 17 android 4.1.2 API 16 android 4.0.3 API 15 android 4.0   API 14 andr

腾讯微博java(android)sdk新增微博api详细介绍

本文主要介绍腾讯微博android sdk中新增微博有关的8个接口,以及使用的示例代码 注意:以下所有的api示例代码都需要先新建QqTSdkService类对象qqTSdkService并初始化,见sdk使用总介绍 1.8个接口介绍 这8个接口包含了腾讯微博两部分api 1.1.微博相关中的发表一条微博.转播一条微博.回复一条微博.发表一条带图片微博.点评一条微博.发表音乐微博.发表视频微博.发表心情帖子.在api中发表一条微博和发表一条带图片微博合二为一. 1.2.私信相关中的发私信api