eclipse 更改 Android 项目 SDK 级别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4070627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:15:49  来源:igfitidea点击:

Changing Android Project SDK level

androideclipsesdkdowngrade

提问by Bryan Denny

I started writing my first Android app, and chose SDK 2.0.1, before I had an android phone. I wantto test the app on a phone that is Android 1.6. The app itself uses pretty simple stuff, so I'm sure its 1.6 compatible, but I want to change the SDK level from Eclipse.

我开始编写我的第一个 Android 应用程序,并在我拥有 Android 手机之前选择了 SDK 2.0.1。我想在 Android 1.6 的手机上测试该应用程序。该应用程序本身使用非常简单的东西,所以我确定它与 1.6 兼容,但我想从 Eclipse 更改 SDK 级别。

The "default.properties" file in my project tree and naively tried to change from Android 6, but it isn't changeable, but if I try to change it it tells me to change the build.properties of the project. I don't know what that means. I'm not used to eclipse and am still fumbling around it.

我的项目树中的“default.properties”文件天真地尝试从 Android 6 更改,但它不可更改,但是如果我尝试更改它,它会告诉我更改项目的 build.properties。我不知道那是什么意思。我不习惯日食,仍然在摸索。

I went to the project properties and clicked on "Java Build Path", but from there I don't know how to add,remove or edit the libraries.

我转到项目属性并单击“Java 构建路径”,但从那里我不知道如何添加、删除或编辑库。

Basically, I'm asking how to downgrade my project from inside eclipse, so I can export it to a compatible phone.

基本上,我问的是如何从 eclipse 内部降级我的项目,以便我可以将其导出到兼容的手机。

回答by Bryan Denny

You can actually keep the project's targetSDK at the same level, and just use a minSDK value.

您实际上可以将项目的 targetSDK 保持在同一级别,只需使用 minSDK 值即可。

What this means is that your application will target to build against a certain API, but it will let phones with lesser versions of Android than that API to also run the app. The catch is that you have to make sure you don't make any API calls that don't exist in the older versions of Android.

这意味着您的应用程序将针对特定 API 进行构建,但它会让 Android 版本低于该 API 的手机也运行该应用程序。问题是您必须确保不进行任何在旧版 Android 中不存在的 API 调用。

To change this, go to your AndroidManifest.xml and add the following inside of the xml node:

要更改此设置,请转到您的 AndroidManifest.xml 并在 xml 节点内添加以下内容:

<uses-sdk android:minSdkVersion="3" />

This would set your minsdk to Android 1.5. Change it 4 for Android 1.6 and so on.

这会将您的 minsdk 设置为 Android 1.5。将其更改为 4 以适用于 Android 1.6 等。

But if you really want to change the TargetSDK, right click on your project --> properties. Then click the Android tab on the left. Then check the box of the target API you want to build against.

但是如果你真的想改变TargetSDK,右击你的项目--> 属性。然后单击左侧的 Android 选项卡。然后选中要针对其构建的目标 API 的框。

Some more versioning info can be found here.

可以在此处找到更多版本信息。

回答by Raymond Chenon

You can change your the Build Target for your project at any time: Right-click the project in the Package Explorer, select Properties, select Android and then check the desired Project Target.

您可以随时更改项目的构建目标:在包资源管理器中右键单击项目,选择属性,选择 Android,然后检查所需的项目目标。

PS : I'm on Eclipse Helios

PS:我在 Eclipse Helios

http://developer.android.com/guide/developing/eclipse-adt.html

http://developer.android.com/guide/developing/eclipse-adt.html