Android 如果我使用安卓4平台编写应用程序,该应用程序是否可以在安卓2设备上运行?

Android 如果我使用安卓4平台编写应用程序,该应用程序是否可以在安卓2设备上运行?,android,eclipse,sdk,Android,Eclipse,Sdk,我想用Android SDK和Eclipse编写一个应用程序。 我使用SDK管理器安装了Android 4平台,但我想知道,这个应用程序能与Android 2设备一起工作吗?还是只有安卓4设备 谢谢。这取决于您拨打的系统电话。始终在运行不同版本的设备上进行测试,因为某些调用仅适用于某些API级别 在上,您可以看到此信息 (请参见getNumberOfCameras fn灰色条右侧的“自:API级别9”)在应用程序清单XML文件中,必须指定最低和所需的目标SDK版本。 我正在开发一个针对Andro

我想用Android SDK和Eclipse编写一个应用程序。 我使用SDK管理器安装了Android 4平台,但我想知道,这个应用程序能与Android 2设备一起工作吗?还是只有安卓4设备


谢谢。

这取决于您拨打的系统电话。始终在运行不同版本的设备上进行测试,因为某些调用仅适用于某些API级别

在上,您可以看到此信息


(请参见getNumberOfCameras fn灰色条右侧的“自:API级别9”)

在应用程序清单XML文件中,必须指定最低和所需的目标SDK版本。 我正在开发一个针对Android 4.0.3(SDK v15)的应用程序,但必须在2.3.3(SDK v10)上运行


当然,您必须只使用较低的SDK可用功能。 您还应该查看Google支持库,它为旧SDK提供了一些新功能。

//Marcello是ADT r16中引入的一个新工具,它可以自动扫描和检查项目中的新API,并在Eclipse编辑器中显示一个漂亮的错误标记

检查新API的规则,请参阅:

在Eclipse中:


我认为您需要关注的是API。“除上述所有内容外,Android 4.0自然支持以前版本的所有API”@0gravity:但事实并非如此:Android 2设备不支持以后版本的所有API。@Thilo是的,我很高兴你提到了。+1。除了API之外,可能还有其他东西,比如打包选项。最安全的方法是同时安装旧版本的Android SDK,看看你的代码是否也可以使用它。谢谢,这真的很有帮助。但是,当我在Eclipse中创建一个新项目时,我应该选择v15还是v10?通常您希望targetSdkVersion是最新的sdk(现在是v15),除非有特定的原因使用早期版本进行构建。然后,您将使用诸如@TargetAPI、支持库或ActionBarSherlock之类的修饰符来支持旧系统上的早期sdk版本,使其恢复到您的MinSDK版本。如果这两个值不同,Lint将给您一个警告,这个警告是为了提醒您注意我所理解的向后兼容性。
<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="15" />
NewApi
------
Summary: Finds API accesses to APIs that are not supported in all targeted API
versions

Priority: 6 / 10
Severity: Error
Category: Correctness

This check scans through all the Android API calls in the application and
warns about any calls that are not available on *all* versions targeted by
this application (according to its minimum SDK attribute in the manifest).

If your code is *deliberately* accessing newer APIs, and you have ensured
(e.g. with conditional execution) that this code will only ever be called on a
supported platform, then you can annotate your class or method with the
@TargetApi annotation specifying the local minimum SDK to apply, such
as@TargetApi(11), such that this check considers 11 rather than your manifest
file's minimum SDK as the required API level.