ClassNotFoundException的安卓 [英] ClassNotFoundException Android
问题描述
所以,我今天遇到了一个问题,当工作在我的Android程序。我有一个类,它变成了一个XML字符串转换成Java对象(第三方),并能正常工作作为一个普通的Java项目,但在Android上我得到这个奇怪的错误:
06-21 22:44:26.402:DEBUG /应用程序(259):抛出java.lang.ClassNotFoundException:com.package.my code.Class装载机dalvik.system.PathClassLoader@4001b500 06-21 22:44:26.402:DEBUG /应用程序(259):在dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
我隐藏我的应用程序的名字和我的包,原因很明显,但我想知道是否有人曾经遇到过这样的问题。类是在正确的包,这是我添加了一个图书馆。我之前引用其他类在那里,这些可制成。是否还有其他原因 ClassNotFoundException的
被抛出?
谢谢, 杰克
私有静态无效fixClassLoaderIssue()
{
ClassLoader的myClassLoader = MyClass.class.getClassLoader();
Thread.currentThread()setContextClassLoader(myClassLoader)。
}
这是在code我现在有,我相信解决了这个问题。 MyClass的仅仅是一类我在我的项目。就像我说的,共同合作把它拿给我,但似乎pretty的直线前进。
So I ran into a problem today while working on my Android program. I have a class that turns that an XML string into a Java object (third party) and it works fine in as a regular java project but on Android I get this weird error:
06-21 22:44:26.402: DEBUG/App(259): java.lang.ClassNotFoundException: com.package.mycode.Class in loader dalvik.system.PathClassLoader@4001b500 06-21 22:44:26.402: DEBUG/App(259): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
I hide my application name and my package for obvious reasons but I was wondering if anyone has ever encountered problems like this. Class is in the correct package, which is a library I have added. Other classes that I reference before are there and those can be made. Are there any other reasons a ClassNotFoundException
is thrown?
Thanks, Jake
private static void fixClassLoaderIssue()
{
ClassLoader myClassLoader = MyClass.class.getClassLoader();
Thread.currentThread().setContextClassLoader(myClassLoader);
}
This is the code I currently have that I believe fixed this problem. MyClass is just a class I have in my project. Like I said, a co-worked showed it to me, but it seems pretty straight forward.
这篇关于ClassNotFoundException的安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!