Android: Class not found


#1

After I successfully developing and testing my app on iOS, I now moved to the Android sim, but am getting class not found errors. How can I fix the dependencies? I have deleted and re-added the platform/android folder many times…

Here’s my error:

D/PluginManager( 1542): init()
W/System.err( 1542): java.lang.ClassNotFoundException: org.apache.cordova.device.Device
W/System.err( 1542): 	at java.lang.Class.classForName(Native Method)
W/System.err( 1542): 	at java.lang.Class.forName(Class.java:251)
W/System.err( 1542): 	at java.lang.Class.forName(Class.java:216)
W/System.err( 1542): 	at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
W/System.err( 1542): 	at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
W/System.err( 1542): 	at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:195)
W/System.err( 1542): 	at org.apache.cordova.PluginManager.init(PluginManager.java:106)
W/System.err( 1542): 	at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:457)
W/System.err( 1542): 	at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:444)
W/System.err( 1542): 	at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:414)
W/System.err( 1542): 	at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:395)
W/System.err( 1542): 	at com.ionicframework.buyo219524.Buyo.onCreate(Buyo.java:33)
W/System.err( 1542): 	at android.app.Activity.performCreate(Activity.java:5231)
W/System.err( 1542): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err( 1542): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
W/System.err( 1542): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
W/System.err( 1542): 	at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err( 1542): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
W/System.err( 1542): 	at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 1542): 	at android.os.Looper.loop(Looper.java:136)
W/System.err( 1542): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err( 1542): 	at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1542): 	at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 1542): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err( 1542): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err( 1542): 	at dalvik.system.NativeStart.main(Native Method)
W/System.err( 1542): Caused by: java.lang.NoClassDefFoundError: org/apache/cordova/device/Device
W/System.err( 1542): 	... 26 more
W/System.err( 1542): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.cordova.device.Device" on path: DexPathList[[zip file "/data/app/com.ionicframework.buyo219524-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.buyo219524-2, /system/lib]]
W/System.err( 1542): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err( 1542): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
W/System.err( 1542): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
W/System.err( 1542): 	... 26 more
I/System.out( 1542): Error adding plugin org.apache.cordova.device.Device.
W/System.err( 1542): java.lang.ClassNotFoundException: com.ionic.keyboard.IonicKeyboard
W/System.err( 1542): 	at java.lang.Class.classForName(Native Method)
W/System.err( 1542): 	at java.lang.Class.forName(Class.java:251)
W/System.err( 1542): 	at java.lang.Class.forName(Class.java:216)
W/System.err( 1542): 	at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
W/System.err( 1542): 	at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
W/System.err( 1542): 	at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:195)
W/System.err( 1542): 	at org.apache.cordova.PluginManager.init(PluginManager.java:106)
W/System.err( 1542): 	at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:457)
W/System.err( 1542): 	at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:444)
W/System.err( 1542): 	at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:414)
W/System.err( 1542): 	at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:395)
W/System.err( 1542): 	at com.ionicframework.buyo219524.Buyo.onCreate(Buyo.java:33)
W/System.err( 1542): 	at android.app.Activity.performCreate(Activity.java:5231)
W/System.err( 1542): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err( 1542): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
W/System.err( 1542): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
W/System.err( 1542): 	at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err( 1542): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
W/System.err( 1542): 	at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 1542): 	at android.os.Looper.loop(Looper.java:136)
W/System.err( 1542): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err( 1542): 	at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1542): 	at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 1542): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err( 1542): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err( 1542): 	at dalvik.system.NativeStart.main(Native Method)
W/System.err( 1542): Caused by: java.lang.NoClassDefFoundError: com/ionic/keyboard/IonicKeyboard
W/System.err( 1542): 	... 26 more
W/System.err( 1542): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ionic.keyboard.IonicKeyboard" on path: DexPathList[[zip file "/data/app/com.ionicframework.buyo219524-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.buyo219524-2, /system/lib]]
W/System.err( 1542): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err( 1542): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
W/System.err( 1542): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:457)

#2

Does the app still work?
It may just be an issue with a plugin rather than an issue with your app.


#3

I think it depends on the installation. On the first computer, it gives me the error. On another I did a fresh Android installation an it runs there now.

However, it does not work. It might be some CORS issue + I am using LeafletJS .
How can I really step-by-step debug the Android emulator? I like the Safari feature where you can hook into iOS. Does something similar exist?

Thanks,
EL


#4

Yes, if you’re targeting android 4.4+, you can use chrome to debug the app.