简体   繁体   English

Android开发,SDK版本

[英]Android Development, SDK Version

First time developing for Android. 第一次为Android开发。

I've noticed that the latest SDK is v4.x but I've noticed informally that most people are running v2.3 我注意到最新的SDK是v4.x,但我非正式地注意到大多数人都在运行v2.3

If I develop an app using the 4.x SDK. 如果我使用4.x SDK开发应用程序。 will it refuse to run on 2.3 phones? 会拒绝在2.3手机上运行吗? Or will certain features be disabled? 还是会禁用某些功能?

Should I develop using the 2.3 SDK instead? 我应该使用2.3 SDK进行开发吗?

Before answering the question, something should be cleared up: There's a difference between the version of Android (2.3, 4.x, etc) and the version of the API it runs on (which is ALWAYS an integer: 10,11,12, etc). 在回答问题之前,应先进行以下清理:Android版本(2.3、4.x等)与其运行的API版本(始终为整数:10、11、12,等等)。 The relationship between Android platforms and their respective API versions can be found on this page . 可以在此页面上找到Android平台及其各自的API版本之间的关系。 By way of example, Android 2.3 uses API 10, and Android 4.0 uses API 15. 举例来说,Android 2.3使用API​​ 10,而Android 4.0使用API​​ 15。

Furthermore, there's only one SDK, which has downloadable modules for coding against various versions of the API. 此外,只有一个SDK,其中包含可下载的模块,用于针对各种版本的API进行编码。 So it's not that you're using v4.x of the SDK, it's that you're using the SDK, period, and coding against version 15 of the API :). 因此,并不是您在使用SDK的v4.x,而是您在使用SDK,句点以及针对API版本15的编码:)。

That said: The best thing to do is set minSdkVersion to the minimum version of Android your application will run on, and set targetSdkVersion to the most current version of Android. 就是说:最好的做法是将minSdkVersion设置为将运行您的应用程序的最低Android版本,并将targetSdkVersion设置为最新的Android版本。 Then you can use Build.VERSION_CODES to check for new versions of the platform at runtime, and activate new platform features as necessary. 然后,您可以使用Build.VERSION_CODES在运行时检查平台的新版本,并根据需要激活新的平台功能。 A good tutorial on how to do this is on the Android Developer blog, titled How to have your cupcake, and eat it too . 关于如何执行此操作的一个很好的教程位于Android Developer博客上,标题为“ 如何拿起蛋糕,也可以吃它”

I would even recommend targeting 2.2 as I still have a large number of users (16%) running Android 2.2. 我什至建议使用2.2,因为我仍然有大量的用户(16%)运行Android 2.2。 Here is a break down of on one of my apps that shows what version users are currently running. 这是我的一个应用程序的细分,其中显示了用户当前正在运行的版本。 ( See attached picture ). 见附图 )。 Like J. Maes said the lower you can build it the more users you can capture. 就像J. Maes所说的那样,构建的越少,您捕获的用户就越多。 Although there are trade-offs that you will have to make by using an older SDK. 尽管需要使用较旧的SDK进行权衡。 For most purposes I haven't had much of an issue targeting 2.2. 在大多数情况下,针对2.2的问题并不多。 It allows me access to a larger customer base. 它使我可以接触到更大的客户群。

You should use the lowest version that supports all the features you want to use in your app. 您应使用支持您要在应用程序中使用的所有功能的最低版本。 If you think a 4.x feature is absolutely necessary in you app, then you should use it. 如果您认为4.x功能在您的应用程序中绝对必要,那么您应该使用它。 If not, use 2.3, so more people can run it as Android is backwards compatible. 如果不是,请使用2.3,因为Android向后兼容,因此可以有更多人运行它。

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

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