在较低的SDK上以较高的SDK运行应用 [英] Run app with higher SDK on lower SDK

查看:78
本文介绍了在较低的SDK上以较高的SDK运行应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道以Android 3.0开发的应用程序是否可以在Android 2.1上运行.如果是这样,我该怎么办?

I wanted to know whether an app developed in Android 3.0 runs on Android 2.1. If so, how can I do that?

如果我使用3.0之类的库(例如片段)来开发应用程序,它将在2.1中运行吗?

If I develop the app using the libraries from 3.0 such as fragments, will it work in 2.1?

推荐答案

可以编写针对3.0的应用程序,该应用程序也可以在2.1下运行.但是,它需要仔细使用库和兼容性库.

It is possible to write an app targeted for 3.0 that also runs under 2.1. However, it requires careful use of libraries and the Compatibility library.

第一步是在清单文件中设置适当的android:minSdkVersionandroid:targetSdkVersion值.这将定义允许您的应用运行的设备范围.

The first step is to set appropriate android:minSdkVersion and android:targetSdkVersion values in your manifest file. This will define which range of devices will allow your app to run.

第二个目的是确保您在较低版本的平台上不使用更高版本SDK中的任何API函数-尝试(例如尝试在2.2设备上使用ActionBar)将导致您的应用崩溃.

The second is to ensure you do not use any API functions from later SDKs on platforms with lower versions - attempts (such as trying to use ActionBar on a 2.2 device) will cause your app to crash.

我强烈建议阅读Reto Meier关于保持向后兼容性的文章: http://blog.radioactiveyak.com/2011/01/how-to-use-gyroscope-api-and-remain.html http://blog.radioactiveyak.com/2011/02/strategies-for-honeycomb-and-backwards.html

I'd strongly recommend reading Reto Meier's articles on maintaining backwards compatibility: http://blog.radioactiveyak.com/2011/01/how-to-use-gyroscope-api-and-remain.html http://blog.radioactiveyak.com/2011/02/strategies-for-honeycomb-and-backwards.html

此外, Google I/O应用的来源绝对值得研究他们如何处理在各种设备上运行的方式,同时仍然利用Honeycomb(及更高版本)版本的功能.

In addition, the source for Googles I/O app is definitely worth examining to see how they handle running on a wide range of devices, whilst still utilising features of Honeycomb (and later) releases.

这篇关于在较低的SDK上以较高的SDK运行应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆