danmichaelo / cordova-plugin-appinfo

Cordova plugin that provides a method for getting the app version number across platforms (iOs, Android, WP8, Windows)
MIT License
21 stars 16 forks source link

Android plugin returns error "Class not found" #3

Closed robations closed 10 years ago

robations commented 10 years ago

Hi, thanks for the plugin - works in iOS as expected.

On Android I get an error returned in appinfo.js, Class not found.

Cordova version 3.5.0 Android version 4.4.3

Using adb logcat I get this exception trace:

W/System.err(19512): java.lang.ClassNotFoundException: com.yezhiming.cordova.AppInfo
W/System.err(19512):    at java.lang.Class.classForName(Native Method)
W/System.err(19512):    at java.lang.Class.forName(Class.java:251)
W/System.err(19512):    at java.lang.Class.forName(Class.java:216)
W/System.err(19512):    at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
W/System.err(19512):    at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
W/System.err(19512):    at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:281)
W/System.err(19512):    at org.apache.cordova.PluginManager.execHelper(PluginManager.java:232)
W/System.err(19512):    at org.apache.cordova.PluginManager.exec(PluginManager.java:227)
W/System.err(19512):    at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
W/System.err(19512):    at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(19512):    at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
W/System.err(19512):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(19512):    at android.os.Looper.loop(Looper.java:136)
W/System.err(19512):    at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err(19512): Caused by: java.lang.NoClassDefFoundError: com/yezhiming/cordova/AppInfo
W/System.err(19512):    ... 14 more
W/System.err(19512): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.yezhiming.cordova.AppInfo" on path: DexPathList[[zip file "/data/app/com.example.myapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.myapp-1, /vendor/lib, /system/lib]]

I've checked the plugin is installed (re-added using cordova cli, the plugin is listed in plugins/android.json, and in .../res/xml/config.xml).

I'm unsure how to get any further. Please let me know if you have any ideas how to debug this.

robations commented 10 years ago

It seems like (on cordova build) the plugin is set up in .../res/xml/config.xml like this:

<feature name="AppInfo">
    <param name="android-package" value="com.yezhiming.cordova.AppInfo" />
</feature>

whereas value should, I suppose, be com.yezhiming.cordova.appinfo.AppInfo.

danmichaelo commented 10 years ago

Hm, I'm a bit confused how you got that value. If you use the original plugin, it should be org.scriptotek.appinfo.AppInfo, like so:

    <feature name="AppInfo">
        <param name="android-package" value="org.scriptotek.appinfo.AppInfo" />
    </feature>
robations commented 10 years ago

Ha... sorry for the confusion, check this out:

http://plugins.cordova.io/#/package/com.yezhiming.cordova.appinfo

It even references your repo in the readme, but then all the namespaces are changed. I removed the other plugin and installed yours, and (after removing some zombie references) it's all working :)

danmichaelo commented 10 years ago

Np, and thanks for the link. A situation with two different identifiers for the same plugin is not good. I'll try to contact @yezhiming to see if we can clean this up.