简体   繁体   English

为我的Android应用程序选择正确的API级别

[英]Choosing the right API Level for my android application

I currently have a application targeted at android 2.3 (api level 10), but went thinking that probably people using android 2.1/2.2 or older won't even be able to see the application in the market. 我目前有一个针对android 2.3(api等级10)的应用程序,但认为可能使用Android 2.1 / 2.2或更早版本的人甚至无法在市场上看到该应用程序。

So I thought that using api level 3 would be the best to use, but I don't know if this will maybe make certain elements in my app work less good, and probably buggier, since it actually uses old android code. 所以我认为使用api level 3将是最好用的,但我不知道这是否会使我的应用程序中的某些元素工作不太好,并且可能是buggier,因为它实际上使用了旧的android代码。 Is there a good way to find out which API level I should use, and also, how do I convert my application to that level? 有没有一个很好的方法来找出我应该使用哪个API级别,以及如何将我的应用程序转换为该级别?

You can find a breakdown of the different versions of Android in use here . 您可以在此处找到不同版本的Android的细分。 Currently, if you target 2.1 (API 7) you'll only miss out on about 3% of the market. 目前,如果您的目标是2.1(API 7),那么您只会错过大约3%的市场份额。 Targeting 2.2 will miss just under 20%, or a fifth of the market. 目标2.2将错过不到20%,或市场的五分之一。

As for converting your app, you can check what API level things are available for in the Android Reference . 至于转换您的应用,您可以在Android参考中查看可用的API级别。 You'll note a checkbox and dropdown menu on the top right of the browsing area that allows you to filter by API level - that's one way to help converting. 您会在浏览区域的右上角看到一个复选框和下拉菜单,允许您按API级别进行过滤 - 这是帮助转换的一种方法。 The other is to set the target and minimum SDK versions which will help Eclipse know what to complain about in your code. 另一种是设置目标和最小SDK版本,这将有助于Eclipse知道在代码中抱怨什么。 The easiest way to see if something needs conversion, however, is to emulate and test. 然而,查看某些东西是否需要转换的最简单方法是模拟和测试。

EDIT : The API level dropdown moved from the top right to the top left, over the list of APIs. 编辑 :API级别下拉列表在API列表中从右上角移动到左上角。

此图表可以帮助您下​​定决心。

It is good to look at backward compatibility and in general, you should compile your application against the lowest possible version of the platform that your application can support. 查看向后兼容性是很好的,通常,您应该针对应用程序可以支持的最低版本的平台编译应用程序。

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. 确定最低版本后,应使用相应的平台版本(和API级别)创建AVD并完全测试应用程序。 Make sure to declare a android:minSdkVersion attribute in the application's manifest and set its value to the API Level of the platform version. 确保在应用程序的清单中声明了android:minSdkVersion属性,并将其值设置为平台版本的API级别。 Good luck! 祝好运!

If you have 如果你有

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

then it will appear right down to 1.6, but make sure you don't use antyhing that they don't have in their API 然后它会显示为1.6,但请确保您不使用他们的API中没有的antyhing

edit: Don't bother with 3! 编辑:不要打扰3! :) :)

I started out developing for 1.5, but soon realized that only a small percentage of people still run 1.5. 我开始开发1.5,但很快意识到只有一小部分人仍然运行1.5。 I generally develop at the 2.1 level, and leave it at that (unless you need features at a higher level). 我通常在2.1级开发,并保持不变(除非你需要更高级别的功能)。 To change it, open your project properties, and while I don't have my environment open, there is an Android option where you will select what API level you want to target. 要更改它,打开项目属性,虽然我没有打开环境,但有一个Android选项,您可以在其中选择要定位的API级别。

The Best API Level is contains follows 1) The best API covers 100% market but all are not prefect so our app should be covered at least 90% with all devices . 最佳API级别包含以下内容:1)最佳API涵盖100%市场,但并非完美,因此我们的应用程序应至少覆盖所有设备的90%。

2)We have to care about backward compatibility issues and our code would adapt itself for upcoming versions. 2)我们必须关注向后兼容性问题,我们的代码将适应即将推出的版本。

3) Using the new Android SDK is a requirement to use any of the new APIs added in that level. 3)使用新的Android SDK是使用该级别添加的任何新API的要求。 It should be emphasized ... It is ultimately a business decision on whether supporting an additional 3% of devices is worth the development and testing . 应该强调的是......最终是否需要支持额外3%的设备值得开发和测试。 4) check out this link https://developer.android.com/guide/practices/compatibility.html#defined 4)查看此链接https://developer.android.com/guide/practices/compatibility.html#defined

5) Finally choose the best API you will find best API 5)最后选择最好的API,你会找到最好的API

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

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