简体   繁体   English

Android:android:targetSdkVersion和android:maxSdkVersion

[英]Android: android:targetSdkVersion and android:maxSdkVersion

如何使用android:targetSdkVersionandroid:maxSdkVersion xml属性?

The attributes android:minSdkVersion, android:maxSdkVersion let you specify the range of devices your app will support which will be used by Google to filter its content. android:minSdkVersion, android:maxSdkVersion属性允许您指定应用支持的设备范围, Google将使用这些设备来过滤其内容。

Say you have Android version 11 ie Honeycomb on you device and I make an app and I specify android:minVersion = "14" (ie ICS ), then my app will not be shown in your device's Play Store , similarly the android:maxVersion serves the same purpose. 假设您在设备上安装了Android 版本11Honeycomb并且我制作了应用程序并指定了android:minVersion = "14" (即ICS ),那么我的应用程序将不会显示在您设备的Play商店中 ,类似于android:maxVersion服务同样的目的。

The attribute android:targetSdkVersion is used by the developers to specify the platform they are targeting the most, lets say 70% of Android device users have version 10 ie Gingerbread on their phones so it will be a better option for the developer to test the app on 2.3 devices and specify android:targetSdkVersion to the same. 开发人员使用属性android:targetSdkVersion来指定他们最瞄准的平台,假设有70%的Android设备用户在他们的手机上使用版本10即Gingerbread ,因此对于开发人员来说测试应用程序是更好的选择在2.3设备上并指定android:targetSdkVersion为相同。

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

Description: Lets you express an application's compatibility with one or more versions of the Android platform, by means of an API Level integer. 描述:允许您通过API级别整数表达应用程序与Android平台的一个或多个版本的兼容性。 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. 应用程序表示的API级别将与给定Android系统的API级别进行比较,这可能因不同的Android设备而异。

Attributes: 属性:

android:minSdkVersion An integer designating the minimum API Level required for the application to run. android:minSdkVersion一个整数,指定运行应用程序所需的最低API级别。 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. 如果系统的API级别低于此属性中指定的值,则Android系统将阻止用户安装应用程序。 You should always declare this attribute. 您应该始终声明此属性。

android:targetSdkVersion 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. android:targetSdkVersion此属性通知系统您已针对目标版本进行了测试,系统不应启用任何兼容性行为来维护应用程序与目标版本的向前兼容性。 The application is still able to run on older versions (down to minSdkVersion). 该应用程序仍然可以在旧版本(低至minSdkVersion)上运行。

android:maxSdkVersion An integer designating the maximum API Level on which the application is designed to run. android:maxSdkVersion一个整数,指定应用程序运行的最大API级别。

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. 在Android 1.5,1.6,2.0和2.0.1中,系统在安装应用程序时以及在系统更新后重新验证应用程序时检查此属性的值。 In either case, if the application's maxSdkVersion attribute is lower than the API Level used by the system itself, then the system will not allow the application to be installed. 在任何一种情况下,如果应用程序的maxSdkVersion属性低于系统本身使用的API级别,则系统将不允许安装应用程序。 In the case of re-validation after system update, this effectively removes your application from the device. 在系统更新后重新验证的情况下,这会有效地从设备中删除您的应用程序。

More in Details 更多细节

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eample.tut"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />****
<uses-permission android:name="android.permission.INTERNET"/>
<application
....
</application>
</manifest>

Just to add to what Alexis wrote, these XML tags are how the Google Play Store knows which devices your application can deploy to. 只是为了添加Alexis写的内容,这些XML标签就是Google Play商店如何知道应用程序可以部署到哪些设备。 It will also affect which levels of the API you can use during development. 它还会影响您在开发过程中可以使用的API级别。 If you're ever wondering exactly how far back you should support, check out the pie graph on the Android Dashboard page to see the breakdown of current devices. 如果你想知道你应该支持多久,请查看Android Dashboard页面上的饼图,以查看当前设备的细分。

In your android manifest write (example): 在你的android清单中写(示例):

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

See this for more informations. 为更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM