因此,几天来我一直在努力将现有项目导入到 Eclipse 中,我终于弄明白了。我导入了所有需要的库项目,它工作正常,但还有一个错误。
库项目“PortraitQR”旁边有一个红色的“x”标记,上面写着“无法解析目标 'android-8'”。
无论如何,我尝试编译应用程序,但它崩溃了,这是 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.access$600(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
我对如何修复 android-8 解决目标错误进行了一些研究,但是如果导入库后立即显示错误,我无法找到任何地方该怎么做。人们在使用 SDK 管理器进行更新时通常会出现此错误。