NoClassDefFoundError的为code在Android上的Java库 [英] NoClassDefFoundError for code in an Java library on Android
问题描述
我遇到一个错误常常在我的用户。在启动过程中应用程序崩溃。当MainActivity应该被加载在VM显然不能找到类。我想不通为什么。该应用程序的体系结构是,有两个自由我的亲和版本是使用一个共同的项目。不知道这是否是相关的。请参阅下面的堆栈跟踪。有什么想法?
I am experiencing an error quite often among my users. The app crashes during startup. When the MainActivity is supposed to be loaded the VM apparently cannot find the class. I cannot figure out why. The architecture of the app is that there is a common project that both my free and pro version are using. Don't know if it is relevant. See the stack trace below. Any thoughts?
java.lang.NoClassDefFoundError: com.android.common.MainActivity
at com.mycompany.myapp.Splash.onCreate(Splash.java:23)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.android.common.MainActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.android.pro-1.apk]
编辑:
感谢您下面的评论,理查。现在,我已经改变了 com.android.Splash
别的东西。这不是真正的类名呢。我的坏...!
Thanks for the comment below, Richard. Now I have changed com.android.Splash
to something else. It wasn't the real classname anyway. My bad...!
推荐答案
我有同样的问题,我做了以下解决这个问题。
I had the same issue, I did the following to fix the problem.
- 进入该项目的属性。
- 选择Java构建路径
- 选择排序和导出标签
- 您应该看到所选项目的SRC和根的路径和依存关系在这里。
- 他们是如何排列的顺序是先SRC,然后在根的路径
- 在我切换他们,让根文件夹的SRC之前建立
创 - 自动code项目(从依赖和参考)
的src - 源$ C $ C项目
gen - automated code in project (from dependencies and references)
src - source code in project
没有必要重新启动Eclipse的。它刚开始工作。
There was no need to restart the Eclipse. It just started working.
老实说,我从来没有尝试过机器人工具>修复项目属性,有时可能会做同样的事情。我不知道,我只是没有上面后看到错误信息,以为事情是错误的构建路径。
Honestly I have never tried "Android Tools > Fix Project Properties", sometimes it might be doing the same thing. I do not know, I just did above after seen the error message, thinking something is wrong with the build paths.
修改
后来是不够的,我再次得到错误。然后,我选中所有在该视图中所列的依赖关系。现在,它的工作原理了。到目前为止,一切都很好。我会保持这个更新,如果再次失败。
Later on it was not sufficient, I was getting the error again. Then I "checked" all the dependencies listed in that view. Now it works again. So far so good. I will keep this updated if it fails again.
仅供参考:在我的最后一次尝试,我想机器人工具>修复项目属性,但它没有工作对我来说
FYI: in my last attempt, I tried "Android Tools > Fix Project Properties", but it didn't work out for me.
这篇关于NoClassDefFoundError的为code在Android上的Java库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!