Unable to compile for Android (Dx unsupported class file version 52.0)

1,314 views
Skip to first unread message

Tomaž Kunaver

unread,
Nov 9, 2016, 2:50:05 AM11/9/16
to XStream User
Hi,
I'm new to XStream and have the following problem. I'm using the latest XStream from the web site in my LibGDX project. I'm using Eclipse 4.3 (Kepler). When I run my LibGDX project for Desktop target, everything works ine (XStream loads and saves XMLs just fine), but when I run it for Android target, it fails with the following message:

[2016-11-09 08:45:48 - Supergalactix-android] Dx
PARSE ERROR:
[2016-11-09 08:45:48 - Supergalactix-android] Dx unsupported class file version 52.0
...while parsing com/thoughtworks/xstream/converters/reflection/LambdaConverter.class
[2016-11-09 08:45:48 - Supergalactix-android] Dx 1 error; aborting
[2016-11-09 08:45:48 - Supergalactix-android] Conversion to Dalvik format failed with error 1

I guess the problem is that I have my compiler compliance level set to Java 1.6. I actually can't use 1.8 since Kepler has max. 1.7 (I tried 1.7 and it returns the same error). Anyway, what can I do about it? It works fine on Desktop though (with 1.6 compliance level), it's just the Android that is the problem.

Jörg Schaible

unread,
Nov 9, 2016, 3:58:01 AM11/9/16
to xstrea...@googlegroups.com
Hi Tomaž,
See my answer to https://github.com/x-stream/xstream/issues/49

Cheers,
Jörg

Tomaž Kunaver

unread,
Nov 9, 2016, 4:27:51 AM11/9/16
to XStream User, joerg.s...@bpm-inspire.com
Hi,
I removed the two files you mentioned in that post and now there are other problems. If I try to run it for desktop target (which worked perfectly fine before), I get the following error:

Exception in thread "LWJGL Application" com.thoughtworks.xstream.InitializationException: Could not instantiate mapper : com.thoughtworks.xstream.mapper.LambdaMapper
at com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:627)
at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:604)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:568)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:465)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:350)
at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:64)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:147)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.mapper.LambdaMapper
at com.thoughtworks.xstream.core.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:148)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:623)
... 9 more

If I try to run it for android target, I get a new error:
[2016-11-09 10:23:04 - Supergalactix-android] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser;

However, wouldn't be easier if you put together a release that works on Android? Would be much easier than us trying to hack around it to make it work on Android.

Jörg Schaible

unread,
Nov 9, 2016, 4:42:29 AM11/9/16
to xstrea...@googlegroups.com
Hi Tomaž,

Tomaž Kunaver wrote:

[snip]

> I removed the two files you mentioned in that post and now there are other
> problems. If I try to run it for desktop target (which worked perfectly
> fine before), I get the following error:
>
> Exception in thread "LWJGL Application"
> com.thoughtworks.xstream.InitializationException: Could not instantiate
> mapper : com.thoughtworks.xstream.mapper.LambdaMapper at
> com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:627)
> at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:604) at
> com.thoughtworks.xstream.XStream.<init>(XStream.java:568) at
> com.thoughtworks.xstream.XStream.<init>(XStream.java:496) at
> com.thoughtworks.xstream.XStream.<init>(XStream.java:465) at
> com.thoughtworks.xstream.XStream.<init>(XStream.java:411) at
> com.thoughtworks.xstream.XStream.<init>(XStream.java:350) at
> com.mygdx.game.MyGdxGame.create(MyGdxGame.java:64) at
>
com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:147)
> at
>
com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
> Caused by: java.lang.ClassNotFoundException:
> com.thoughtworks.xstream.mapper.LambdaMapper at
>
com.thoughtworks.xstream.core.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:148)
> at java.lang.Class.forName0(Native Method) at
> java.lang.Class.forName(Class.java:348) at
> com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:623)
> ... 9 more

It seems you try to run this with a Java 8 runtime.

> If I try to run it for android target, I get a new error:
> [2016-11-09 10:23:04 - Supergalactix-android] Conversion to Dalvik format
> [failed: Unable to execute dex: Multiple dex files define
> [Lorg/xmlpull/v1/XmlPullParser;

You're the first reporting this. It might be the result from the dependency
to the xpp3 parser. Try to exclude this dependency. AFAICS you have already
an XmlPullParser available on Android (see FAQ).

> However, wouldn't be easier if you put together a release that works on
> Android? Would be much easier than us trying to hack around it to make it
> work on Android.

I have no expertise for Android nor any resources to setup a test platform
or something alike. Anything in XStream related to Android was reported by
other users.

The easiest solution would be a possibility to tell the Dalvik parser to
ignore those two files, but I don't know if this is possible.

Cheers,
Jörg

Tomaž Kunaver

unread,
Nov 9, 2016, 4:53:00 AM11/9/16
to XStream User, joerg.s...@bpm-inspire.com
Well, there might be another solution - building the whole thing from sources without those two files. Could perhaps you do it and send me in the jar file? I'm having troubles building it, I'm not too swift with it (and I'm on Windows)...

Jörg Schaible

unread,
Nov 9, 2016, 6:18:20 AM11/9/16
to xstrea...@googlegroups.com
Hi Tomaž,

Tomaž Kunaver wrote:

There's no difference to a jar file where you've removed those two class
files.

Cheers,
Jörg

Reply all
Reply to author
Forward
0 new messages