ExceptionInInitializerError because it did not find MessageBufferU
See original GitHub issueHi,
I’m trying to upgrade from msgpack 0.5.3 to 0.7.0-M6.
Followed the example from: https://github.com/msgpack/msgpack-java/blob/v07-develop/msgpack-core/src/test/java/org/msgpack/core/example/MessagePackExample.java, but my app always crashes with this error:
08-22 19:47:37.532 9501-9501/com.myapp.dev E/AndroidRuntime? FATAL EXCEPTION: main java.lang.ExceptionInInitializerError at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35) at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153) at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158) at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.msgpack.core.buffer.MessageBufferU at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:141) at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35) at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153) at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158) at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.ClassNotFoundException: org.msgpack.core.buffer.MessageBufferU at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:127) at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35) at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153) at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158) at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.NoClassDefFoundError: org/msgpack/core/buffer/MessageBufferU at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:127) at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35) at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153) at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158) at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.msgpack.core.buffer.MessageBufferU" on path: DexPathList[[zip file "/data/app/com.myapp.dev-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.dev-1, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:127) at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35) at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153) at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158) at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448)
Do i have to add some extra stuff in the app’s dependencies? It fails when i try to do any kind of packing.
Any suggestions on how to fix this ? Thanks
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (4 by maintainers)
@akanshSirohi Oh boy. That was such a long time ago 😄
The issue was that we were using Proguard to obfuscate the code and msgpack didn’t like the fact that it’s classes had their name changed (or they would outright not be bundled in the resulting apk). The fix was to just mark the particular class to be kept with the same name & to be bundled in the apk.
Something like
-keep class javax.** { *; }
Can’t give you the exact example as i’m no longer working on that project and i don’t have access to the source code anymore
@MereutaRadu Thank you so much for this elaborated and quick reply!!! I really appreciate it! 😁 I got it working using the rule below, hope it helps someone in future.