eclipse 导入库后无法解析目标“android-8”

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

Unable to resolve target 'android-8' after importing libraries

javaandroideclipse

提问by Guy

So I've been struggling with importing an existing project to eclipse for a few days now and I've finally figured it out. I imported all the needed library projects and it works fine, but there's one more error.

所以几天来,我一直在努力将现有项目导入到 eclipse 中,我终于弄明白了。我导入了所有需要的库项目,它运行良好,但还有一个错误。

Library project 'PortraitQR' has a red 'x' mark next to it says 'Unable to resolve target 'android-8''.

库项目“PortraitQR”旁边有一个红色的“x”标记,上面写着“无法解析目标“android-8”。

I tried to compile the application anyway but it crashes, here's the logcat file:

我无论如何都试图编译该应用程序,但它崩溃了,这是 logcat 文件:

07-16 18:24:14.296: E/AndroidRuntime(9673): FATAL EXCEPTION: main
07-16 18:24:14.296: E/AndroidRuntime(9673): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{si.dvanadva.evanturist/si.dvanadva.evanturist.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-2.apk
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.ActivityThread.access0(ActivityThread.java:141)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.os.Looper.loop(Looper.java:137)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.ActivityThread.main(ActivityThread.java:5041)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at java.lang.reflect.Method.invokeNative(Native Method)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at java.lang.reflect.Method.invoke(Method.java:511)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at dalvik.system.NativeStart.main(Native Method)
07-16 18:24:14.296: E/AndroidRuntime(9673): Caused by: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-2.apk
07-16 18:24:14.296: E/AndroidRuntime(9673):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-16 18:24:14.296: E/AndroidRuntime(9673):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
07-16 18:24:14.296: E/AndroidRuntime(9673):     ... 11 more

I did some research on how to fix android-8 resolve target error, but I can't find anywhere what to do if the error shows as soon as you import libraries. People usually have this error when updating with SDK manager.

我做了一些关于如何修复 android-8 解决目标错误的研究,但是如果在您导入库后立即显示错误,我无法找到该怎么做。人们在使用 SDK 管理器更新时通常会出现此错误。

回答by Guy

I had to open up SDK manager and simply installed API level 8. That solved my problem. Vote up the user in the comments that gave me the solution :)

我不得不打开 SDK 管理器并简单地安装 API 级别 8。这解决了我的问题。在给我解决方案的评论中投票给用户:)

回答by MojAmiri

in some cases after installation you should select the target platform for your project. to do so:

在某些情况下,安装后您应该为您的项目选择目标平台。这样做:

  1. Right click on project->properties.
  2. Select Android on left panel.
  3. If you see Android 4.0.3 in (Project Build Target), then tick it and click Apply button.
  4. If you don't have 4.0.3 version in Build Targets, then you don't have it yet. to install simply go to sdk manager and click on Android 4.0.3(API 15)-SDK Platform.
  1. 右键单击项目-> 属性。
  2. 在左侧面板上选择 Android。
  3. 如果您在 (Project Build Target) 中看到 Android 4.0.3,请勾选它并单击 Apply 按钮。
  4. 如果您在 Build Targets 中没有 4.0.3 版本,那么您还没有它。安装只需转到 sdk 管理器并单击 Android 4.0.3(API 15)-SDK Platform。