java – ClassNotFoundException Android
•
Java
So I encountered a problem when dealing with Android programs I have a class that converts XML strings into Java objects (third-party), which works normally as a regular java project, but I get this strange error on Android:
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 software package for obvious reasons, but I wonder if anyone has encountered such a problem Class is in the correct package. This is the library I added Other courses I have referred to before are there and can be made Is there any other reason for classnotfoundexception?
Thank you, reliable man
Solution
private static void fixClassLoaderIssue()
private static void fixClassLoaderIssue() { ClassLoader myClassLoader = MyClass.class.getClassLoader(); Thread.currentThread().setContextClassLoader(myClassLoader); }
This is the code I currently have. I believe it fixes this problem MyClass is just a class in my project As I said, a collaborator showed it to me, but it seemed very direct
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码