Class Not Found Exception Using Custom Cordova Plugin
Solution 1:
I see that you are pointing to a jar file in your config.xml. If you really want to keep using this jar file make sure that the path is correctly mapped in android platform folders and it matches the classpath.
If you want to do a simple test, you should declare your android source files one by one. So after the node config-file you should add several nodes like this one:
<source-filesrc="src/android/src/net/mydomain/myplugin/MyClass.java"target-dir="src/mydomain/myplugin" />
Solution 2:
This is the most important part of your stacktrace:
Caused by: java.lang.ClassNotFoundException: Didn't find class"com.duplou.cordova.plugin.customprinter.CustomPrinter"
Your Cordova configuration references the CustomPrinter
plugin. When Javascript triggers loading it, the Java class cannot be found and thus your application crashes.
You need to ensure that the Java class is present in your application package.
Solution 3:
I have this error and solved it by change android.json file in \platforms\android\android.json
You must change value of res/xml/config.xml to your package of custom Plugin.
The reason is package of your custom plugin and value of above in not same.
Solution 4:
In my case I had multiple .java files referenced. When I changed the ordering of how it is referenced in plugin.xml, it fixed the problem. Seems like the last .java file is dependent on the second last one.
Before:
<!--libs--><source-filesrc="libs/sample-release.aar"target-dir="libs/" /><source-filesrc="src/android/Licence.java"target-dir="src/android/" /><source-filesrc="src/android/Deserializer.java"target-dir="src/android/" />
After:
<!--libs--><source-filesrc="libs/sample-release.aar"target-dir="libs/" /><source-filesrc="src/android/Deserializer.java"target-dir="src/android/" /><source-filesrc="src/android/Licence.java"target-dir="src/android/" />
So just by switching the ordering, the ClassNotFoundException was resolved.
Post a Comment for "Class Not Found Exception Using Custom Cordova Plugin"