3

我想使用 Android SDK 和 Eclipse 编写一个应用程序。我使用 SDK 管理器安装了 Android 4 平台,但我想知道,这个应用程序是否适用于 Android 2 设备?还是只有 Android 4 设备?

谢谢。

4

3 回答 3

2

Android Lint是 ADT r16 中引入的一个新工具,它会自动扫描并检查您的项目是否有新的 API,并在您的 Eclipse 编辑器中显示一个漂亮的错误标记。

检查新 API 的规则,请参见此处

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.

在 Eclipse 中:

在此处输入图像描述

于 2012-07-04T04:05:15.810 回答
2

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

sdk 网站上,您可以看到此信息。

(参见 getNumberOfCameras fn 灰色条右侧的“Since: API Level 9”)

于 2012-07-04T01:20:57.507 回答
2

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

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

当然,您只能使用较低的 SDK 可用功能。您还应该查看为旧 SDK 提供一些新功能的 Google 支持库。 http://developer.android.com/tools/extras/support-library.html

// 马塞洛

于 2012-07-04T01:25:41.177 回答