Android在Eclipse中更改SDK版本?无法解析目标android-x

时间:2023-01-22 15:06:18

I developed an Android aplication against 2.1 SDK. Since then I have re-installed Eclipse/Android SDK; with the new install, I want to 'upgrade' the dependancy of the Android application to 2.2 SDK (because I dont want 2.1 installed on my machine). Is this possible? I am getting the following error from eclipse:

我开发了针对2.1 SDK的Android应用程序。从那以后我重新安装了Eclipse / Android SDK;使用新安装,我想'升级'Android应用程序的依赖性到2.2 SDK(因为我不想在我的机器上安装2.1)。这可能吗?我从eclipse得到以下错误:

[2010-08-31 18:18:32 - AndroidApplication] Unable to resolve target 'android-7'

7 个解决方案

#1


61  

If you're using eclipse you can open default.properties file in your workspace and change the project target to the new sdk (target=android-8 for 2.2). I accidentally selected the 1.5 sdk for my version and didn't catch it until much later, but updating that and restarting eclipse seemed to have done the trick.

如果您正在使用eclipse,则可以在工作区中打开default.properties文件,并将项目目标更改为新的sdk(target = android-8 for 2.2)。我不小心为我的版本选择了1.5 sdk并且直到很久之后都没有捕获它,但更新并重新启动eclipse似乎已经完成了这个技巧。

#2


16  

go to project properties and change the target from 7 to 8 also change the target in android manifest and also go to properties of project by right clicking on the project and choose the target

转到项目属性并将目标从7更改为8也会更改android清单中的目标,并通过右键单击项目并选择目标来转到项目属性

#3


8  

This can happen when you mistakenly import an Android project into your Eclipse workspace as a Java project. The solution in this case: delete the project from the workspace in the Package Explorer, then go to File -> Import -> Android -> Existing Android code into workspace.

当您错误地将Android项目作为Java项目导入Eclipse工作区时,可能会发生这种情况。在这种情况下的解决方案:在Package Explorer中从工作区中删除项目,然后转到File - > Import - > Android - > Existing Android code into workspace。

#4


5  

I faced the same issue and got it working.

我遇到了同样的问题,并让它发挥作用。

I think it is because when you import a project, build target is not set in the project properties which then default to the value used in manifest file. Most likely, you already have installed a later android API with your SDK.

我认为这是因为在导入项目时,未在项目属性中设置构建目标,然后默认为清单文件中使用的值。最有可能的是,您已经在SDK中安装了以后的Android API。

The solution is to enable build target toward your installed API level (but keep the minimum api support as specified in the manifest file). TO do this, in project properties, go to android, and from "Project Build Target", pick a target name.

解决方案是使构建目标朝向已安装的API级别(但保持清单文件中指定的最小api支持)。要做到这一点,在项目属性中,转到android,并从“Project Build Target”中选择一个目标名称。

#5


3  

In Build: v22.6.2-1085508 ADT you need to add(select Android 4.4.2)

在Build:v22.6.2-1085508 ADT中你需要添加(选择Android 4.4.2)

Goto project --> properties --> Android(This is second in listed item order leftPanel) and in the RightPanel Project Build Target, select Android 4.4.2 as Target name and apply changes It will rebuild the workspace.

转到项目 - >属性 - > Android(这是列出的项目顺序leftPanel中的第二个),在RightPanel项目构建目标中,选择Android 4.4.2作为目标名称并应用更改它将重建工作区。

In my case unable to resolve target 'android-17' eclipse was being shown as compile error and in code: import java.util.HashMap was not being referenced.

在我的情况下无法解决目标'android-17'eclipse被显示为编译错误并且在代码中:导入java.util.HashMap未被引用。

#6


2  

This Problem is because of Path so you need to build the path using following Steps

此问题是由于Path,因此您需要使用以下步骤构建路径

Goto project ----->Right Click on Project Name ---->properties ---->click on Than Java Build Path option than ---> click Android 4.2.2---->Ok

转到项目----->右键单击Project Name ----> properties ---->单击Than Java Build Path选项比--->单击Android 4.2.2 ----> Ok

#7


1  

Goto project -->properties --> (in the dialog box that opens goto Java build path), and in order and export select android 4.1 (your new version) and select dependencies.

转到项目 - >属性 - >(在打开goto Java构建路径的对话框中),并按顺序导出选择android 4.1(您的新版本)并选择依赖项。

#1


61  

If you're using eclipse you can open default.properties file in your workspace and change the project target to the new sdk (target=android-8 for 2.2). I accidentally selected the 1.5 sdk for my version and didn't catch it until much later, but updating that and restarting eclipse seemed to have done the trick.

如果您正在使用eclipse,则可以在工作区中打开default.properties文件,并将项目目标更改为新的sdk(target = android-8 for 2.2)。我不小心为我的版本选择了1.5 sdk并且直到很久之后都没有捕获它,但更新并重新启动eclipse似乎已经完成了这个技巧。

#2


16  

go to project properties and change the target from 7 to 8 also change the target in android manifest and also go to properties of project by right clicking on the project and choose the target

转到项目属性并将目标从7更改为8也会更改android清单中的目标,并通过右键单击项目并选择目标来转到项目属性

#3


8  

This can happen when you mistakenly import an Android project into your Eclipse workspace as a Java project. The solution in this case: delete the project from the workspace in the Package Explorer, then go to File -> Import -> Android -> Existing Android code into workspace.

当您错误地将Android项目作为Java项目导入Eclipse工作区时,可能会发生这种情况。在这种情况下的解决方案:在Package Explorer中从工作区中删除项目,然后转到File - > Import - > Android - > Existing Android code into workspace。

#4


5  

I faced the same issue and got it working.

我遇到了同样的问题,并让它发挥作用。

I think it is because when you import a project, build target is not set in the project properties which then default to the value used in manifest file. Most likely, you already have installed a later android API with your SDK.

我认为这是因为在导入项目时,未在项目属性中设置构建目标,然后默认为清单文件中使用的值。最有可能的是,您已经在SDK中安装了以后的Android API。

The solution is to enable build target toward your installed API level (but keep the minimum api support as specified in the manifest file). TO do this, in project properties, go to android, and from "Project Build Target", pick a target name.

解决方案是使构建目标朝向已安装的API级别(但保持清单文件中指定的最小api支持)。要做到这一点,在项目属性中,转到android,并从“Project Build Target”中选择一个目标名称。

#5


3  

In Build: v22.6.2-1085508 ADT you need to add(select Android 4.4.2)

在Build:v22.6.2-1085508 ADT中你需要添加(选择Android 4.4.2)

Goto project --> properties --> Android(This is second in listed item order leftPanel) and in the RightPanel Project Build Target, select Android 4.4.2 as Target name and apply changes It will rebuild the workspace.

转到项目 - >属性 - > Android(这是列出的项目顺序leftPanel中的第二个),在RightPanel项目构建目标中,选择Android 4.4.2作为目标名称并应用更改它将重建工作区。

In my case unable to resolve target 'android-17' eclipse was being shown as compile error and in code: import java.util.HashMap was not being referenced.

在我的情况下无法解决目标'android-17'eclipse被显示为编译错误并且在代码中:导入java.util.HashMap未被引用。

#6


2  

This Problem is because of Path so you need to build the path using following Steps

此问题是由于Path,因此您需要使用以下步骤构建路径

Goto project ----->Right Click on Project Name ---->properties ---->click on Than Java Build Path option than ---> click Android 4.2.2---->Ok

转到项目----->右键单击Project Name ----> properties ---->单击Than Java Build Path选项比--->单击Android 4.2.2 ----> Ok

#7


1  

Goto project -->properties --> (in the dialog box that opens goto Java build path), and in order and export select android 4.1 (your new version) and select dependencies.

转到项目 - >属性 - >(在打开goto Java构建路径的对话框中),并按顺序导出选择android 4.1(您的新版本)并选择依赖项。