简体   繁体   English

更改Android Project SDK级别

[英]Changing Android Project SDK level

I started writing my first Android app, and chose SDK 2.0.1, before I had an android phone. 在开始使用Android手机之前,我开始编写我的第一个Android应用程序,并选择了SDK 2.0.1。 I wantto test the app on a phone that is Android 1.6. 我想在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. 应用程序本身使用非常简单的东西,所以我确信它的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. 我的项目树中的“default.properties”文件天真地尝试从Android 6更改,但它不可更改,但如果我尝试更改它,它会告诉我更改项目的build.properties。 I don't know what that means. 我不知道这意味着什么。 I'm not used to eclipse and am still fumbling around it. 我不习惯日食,而且还在摸索它。

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 Build Path”,但从那里我不知道如何添加,删除或编辑库。

Basically, I'm asking how to downgrade my project from inside eclipse, so I can export it to a compatible phone. 基本上,我问的是如何从Eclipse中降级我的项目,所以我可以将它导出到兼容的手机。

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. 这意味着您的应用程序将针对某个API进行构建,但它会让那些Android版本比该API更少的手机也可以运行该应用程序。 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. 问题是您必须确保不进行旧版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. 这会将你的minsdk设置为Android 1.5。 Change it 4 for Android 1.6 and so on. 为Android 1.6改变它4,依此类推。

But if you really want to change the TargetSDK, right click on your project --> properties. 但如果您真的想要更改TargetSDK,请右键单击您的项目 - >属性。 Then click the Android tab on the left. 然后单击左侧的Android选项卡。 Then check the box of the target API you want to build against. 然后选中要构建的目标API的框。

Some more versioning info can be found here. 可以在此处找到更多版本信息。

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. 您可以随时更改项目的构建目标:在Package Explorer中右键单击项目,选择Properties,选择Android,然后选中所需的Project Target。

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

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

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