我的项目是一个Meteor应用程序,拥有网络用户和移动用户(在Android和iOS上)。我需要使用Cordova的本机应用程序的原因是因为我需要使用特定的库(已经为Android和iOS编码)。我开发了一个cordova插件,它是我的Meteor应用程序和我的库之间的桥梁。我使用命令meteor add cordova:{plugin_name@bitbucket_url/get/commit_hash.tar.gz}
添加了这个cordova-plugin。然后我用meteor run android-device --verbose
运行我的应用程序,在我的Nexus 5上构建它。
当我查看日志时,我看到没有错误,我也看到我的插件中需要的jar文件是dexed:
-dex:
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/ant-build/classes
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/CordovaLib/ant-build/classes.jar
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/com.google.playservices/google-play-services_lib/ant-build/classes.jar
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/libs/anywaresdk.jar
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/libs/android-async-http-1.4.4.jar
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/com.google.playservices/google-play-services_lib/libs/google-play-services.jar
[dex] input: /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/libs/android-beacon-library-2.0.jar
[dex] Using Pre-Dexed classes-08b5b91946ca0289c8a6c6185a42d50c.jar <- /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/CordovaLib/ant-build/classes.jar
[dex] Using Pre-Dexed classes-df56033b7c34d81e6100d180a5eb093f.jar <- /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/com.google.playservices/google-play-services_lib/ant-build/classes.jar
[dex] Using Pre-Dexed anywaresdk-ebcd8e8b201f2cf0e8f3947837f0a238.jar <- /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/libs/anywaresdk.jar
[dex] Using Pre-Dexed android-async-http-1.4.4-1381083dec2d5e09b669d0f4d8aa7dbb.jar <- /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/libs/android-async-http-1.4.4.jar
[dex] Using Pre-Dexed google-play-services-63680b630aa52e827ce265766636b8d0.jar <- /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/com.google.playservices/google-play-services_lib/libs/google-play-services.jar
[dex] Using Pre-Dexed android-beacon-library-2.0-b9ed313a0085ed5333e28cb89c1128cf.jar <- /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/libs/android-beacon-library-2.0.jar
[dex] Found modified input file
[dex] Converting compiled files and external libraries into /home/raphael/WebstormProjects/skyshow/.meteor/local/cordova-build/platforms/android/ant-build/classes.dex...
[dx] Merged dex A (85 defs/107.7KiB) with dex B (207 defs/313.5KiB). Result is 292 defs/511.4KiB. Took 0.3s
[dx] Merged dex A (292 defs/511.4KiB) with dex B (1 defs/0.4KiB). Result is 293 defs/652.5KiB. Took 0.1s
[dx] Merged dex A (293 defs/652.5KiB) with dex B (72 defs/146.9KiB). Result is 365 defs/1077.0KiB. Took 0.1s
[dx] Result compacted from 1634.2KiB to 597.6KiB to save 1036.6KiB
[dx] Merged dex A (365 defs/1077.0KiB) with dex B (40 defs/59.6KiB). Result is 405 defs/597.6KiB. Took 0.2s
[dx] Merged dex A (405 defs/597.6KiB) with dex B (3422 defs/3053.3KiB). Result is 3827 defs/4345.6KiB. Took 0.4s
[dx] Result compacted from 5460.2KiB to 3712.5KiB to save 1747.7KiB
[dx] Merged dex A (3827 defs/4345.6KiB) with dex B (67 defs/95.6KiB). Result is 3894 defs/3712.5KiB. Took 0.6s
但是当我的应用程序在构建之后启动时,经过几秒钟的执行后,我收到以下错误:
I/art (18645): Rejecting re-init on previously-failed class java.lang.Class<novom.anyware.anywaresdk.AWRAlarmBroadcastReceiver>
I/art (18645): Rejecting re-init on previously-failed class java.lang.Class<novom.anyware.anywaresdk.AWRAlarmBroadcastReceiver>
D/AndroidRuntime(18645): Shutting down VM
--------- beginning of crash
E/AndroidRuntime(18645): FATAL EXCEPTION: main
E/AndroidRuntime(18645): Process: com.id1yih4vymtz45gm5gsdh, PID: 18645
E/AndroidRuntime(18645): java.lang.NoClassDefFoundError: Failed resolution of: Lnovom/anyware/anywaresdk/AWRAlarmBroadcastReceiver;
E/AndroidRuntime(18645): at novom.anyware.anywaresdk.AWRUtils.cancelAlarm(AWRUtils.java:270)
E/AndroidRuntime(18645): at novom.anyware.anywaresdk.AWRSyncService.stopPushService(AWRSyncService.java:413)
E/AndroidRuntime(18645): at novom.anyware.anywaresdk.AWRSyncService.onDestroy(AWRSyncService.java:420)
E/AndroidRuntime(18645): at android.app.ActivityThread.handleStopService(ActivityThread.java:2894)
E/AndroidRuntime(18645): at android.app.ActivityThread.access$2200(ActivityThread.java:144)
E/AndroidRuntime(18645): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
E/AndroidRuntime(18645): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18645): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(18645): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(18645): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18645): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(18645): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(18645): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime(18645): Caused by: java.lang.ClassNotFoundException: Didn't find class "novom.anyware.anywaresdk.AWRAlarmBroadcastReceiver" on path: DexPathList[[zip file "/data/app/com.id1yih4vymtz45gm5gsdh-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(18645): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(18645): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(18645): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(18645): ... 13 more
E/AndroidRuntime(18645): Suppressed: java.lang.NoClassDefFoundError: novom.anyware.anywaresdk.AWRAlarmBroadcastReceiver
E/AndroidRuntime(18645): at dalvik.system.DexFile.defineClassNative(Native Method)
E/AndroidRuntime(18645): at dalvik.system.DexFile.defineClass(DexFile.java:226)
E/AndroidRuntime(18645): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
E/AndroidRuntime(18645): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
E/AndroidRuntime(18645): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
E/AndroidRuntime(18645): ... 15 more
E/AndroidRuntime(18645): Suppressed: java.lang.ClassNotFoundException: novom.anyware.anywaresdk.AWRAlarmBroadcastReceiver
E/AndroidRuntime(18645): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(18645): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(18645): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(18645): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(18645): ... 14 more
E/AndroidRuntime(18645): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
我可以看到一些日志让我知道anywaresdk.jar
文件中的大多数类都是在AWRAlarmBroadcastReceiver
发生错误之前成功使用的。只是为了确保文件存在,我解压缩了jar文件,我找到了可能缺少的类文件......
我还复制了由meteor安装在我的Nexus 5中的apk,将其解压缩并使用android构建工具classes.dex
和类dexdump
输出文件Lnovom/anyware/anywaresdk/AWRAlarmBroadcastReceiver;
的内容被列在其中。
为了确保我的jar文件没有被破坏或者其他东西,我在原生的Android应用程序中使用它们,它们就像假设的那样工作。
当我通过Cordova插件在Meteor应用程序中使用NoClassDefFoundError时,为什么会出现NoClassDefFoundError?
答案 0 :(得分:0)
对于有类似问题的任何人,我的问题是这个文件依赖于support-v4而我没有把它作为我的cordova插件的plugin.xml
中的依赖项。感谢Chris Stratton撰写的文章stackoverflow.com/questions/28686721 / ...