导入项目导致无法解析目标“android-7”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11278319/
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-08-20 06:40:26  来源:igfitidea点击:

Importing project gave Unable to resolve target 'android-7'

androideclipseapisdk

提问by JDS

This app I completed around a year ago (!) but never launched it on the market place. I am trying to open it up in eclipse now to make some small modifications and work on the code a little bit. So I imported it and then found this weird "unable to resolve target" error. It's highlighting every class red in all my 'src' files.

我大约在一年前(!)完成了这个应用程序,但从未在市场上推出它。我现在正在尝试在 eclipse 中打开它以进行一些小的修改并对代码进行一些处理。所以我导入了它,然后发现了这个奇怪的“无法解析目标”错误。它突出显示了我所有“src”文件中的每个类红色。

I've looked at a similar question which said to add the line to default.properties file. My project has a project.properties file which has the line:

我看过一个类似的问题,它说要将行添加到 default.properties 文件。我的项目有一个 project.properties 文件,其中包含以下行:

target=android-7

Any advice how to get this to work? I could always start a new project and just copy all the src files but that would be pretty lame and time-wasting.

任何建议如何让它发挥作用?我总是可以开始一个新项目并只复制所有 src 文件,但这会非常蹩脚和浪费时间。

One more comment - I'm developing on a new computer and I don't think I have the API level 7. Could that be the problem? I've gone into Window --> Android SDK Manager and the oldest available API it shows is level 8. But level 7 will mean I can target more devices I think so I'd like to go with that.

还有一条评论 - 我正在一台新计算机上开发,我认为我没有 API 级别 7。这可能是问题吗?我已经进入 Window --> Android SDK Manager 并且它显示的最旧的可用 API 是 8 级。但是 7 级意味着我可以针对更多我认为的设备,所以我想采用它。

Thank you for any help.

感谢您的任何帮助。

回答by caiocpricci2

Well, yes that is your problem. You don't have the API level 7 downloaded. You can right click the project and go properties->android and select another available API. As long as you don't change the min sdk version in your manifest you are still targeting as many devices as before.

嗯,是的,那是你的问题。您没有下载 API 级别 7。您可以右键单击该项目并转到 properties->android 并选择另一个可用的 API。只要您不更改清单中的 min sdk 版本,您的目标设备仍与以前一样多。

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

Update

更新

You don't have to do this, but you can get the older APIs on the SDK Archives page

您不必这样做,但您可以在SDK Archives 页面上获取较旧的 API

I don't know if there is any official source for the next statement but that is what I found while working. If anybody can complete this with a better answer I would appreciate it very much.

我不知道下一个声明是否有任何官方来源,但这是我在工作时发现的。如果有人能用更好的答案完成这个,我将不胜感激。

You can compile the code with a newer SDK version as long as you don't use any code not compatible to the previous ones.

只要不使用与以前版本不兼容的任何代码,就可以使用较新的 SDK 版本编译代码。

Example:

例子:

I want my app to be available for API level 7. But i only have API level 15 installed. As long as I keep the minSdkVersion="7" in my Manifest and don't use any resource not available in the previous APIs the app will work just fine on my targeted devices.

我希望我的应用程序可用于 API 级别 7。但我只安装了 API 级别 15。只要我在 Manifest 中保留 minSdkVersion="7" 并且不使用任何在以前的 API 中不可用的资源,该应用程序就可以在我的目标设备上正常运行。

回答by John

For anyone who wants to test their project against an API level that isn't the most recent one, you can just use the SDK Manager to install the old SDK:

对于想要针对非最新 API 级别测试其项目的任何人,您只需使用 SDK 管理器来安装旧 SDK:

In Eclipse (with adt installed):

在 Eclipse 中(安装了 adt):

enter image description here

在此处输入图片说明

SDK Manager:

SDK经理:

enter image description here

在此处输入图片说明

Just check the box of the SDK you want to use to test against your project and click install. You can also remove API's that you aren't using.

只需选中要用于测试项目的 SDK 框,然后单击安装。您还可以删除不使用的 API。

回答by vovahost

Right click on your project then:

右键单击您的项目,然后:

Properties -> Android -> Project build target -> Check Android 4.1.2

属性 -> Android -> 项目构建目标 -> 检查 Android 4.1.2

回答by Sumit Munot

In your application's manifest.xml file add this tag

在应用程序的 manifest.xml 文件中添加此标记

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

It's worked for me. Try it.

它对我有用。尝试一下。

回答by user3628683

I resolved this issue by editing my project.properties file
from: target=android-7
to: target=android-19.

我通过编辑我的 project.properties 文件
从: target=android-7
to:解决了这个问题target=android-19

I also changed the target sdk version in the manifest file:
android:targetSdkVersion="19".

我还在清单文件中更改了目标 sdk 版本:
android:targetSdkVersion="19".

回答by Xubing in China. Developer

  1. check android:minSdkVersion= in the AndroidManifest.xml

  2. update target=android- in the project.properties if you use Eclipse IDE

  1. 在 AndroidManifest.xml 中检查 android:minSdkVersion=

  2. 如果您使用 Eclipse IDE,请更新 project.properties 中的 target=android-

回答by user205871

Yes. I see the same problem when I import the android support v7 project as a library project in my own project,the eclipse says that cannot resolve android16, I find that it's the problem of the eclipse,you can right-click your project which has this problem,and then select properties,the Android pane,there is a Project Build Target pane there,you can see it easily,choose a standard android platform,like Android4.3,not others that start with Google API,I hope that this will help you!

是的。我在自己的项目中将android support v7项目作为库项目导入时,也出现同样的问题,eclipse说无法解析android16,我发现是eclipse的问题,你可以右键你的项目有这个问题,然后选择属性,Android窗格,那里有一个Project Build Target窗格,你可以很容易地看到它,选择一个标准的Android平台,比如Android4.3,而不是其他以Google API开头的,我希望这会帮你!