0

Hi all I am trying to use javax.json-b with Android and getting errors. So I include the library in gradle using this line:

implementation group: 'javax.json.bind', name: 'javax.json.bind-api', version: '1.0'

Then import it the usual way:

import javax.json.bind.annotation.JsonbProperty

Compiles fine but when I run it on any device it gives me this:

../../../home/.gradle/caches/modules-2/files-2.1/javax.json.bind/javax.json.bind-api/1.0/10332203cb05f4ab2e8bf058bfd7d99648c5ca68/javax.json.bind-api-1.0.jar
Illegal class file: Class module-info is missing a super type.

So I cleared the gradle cache incase it was a bad version, same happened, I removed the import implementation line from the build.gradle file and downloaded the jar from the maven repository but I got a similar issue.

I thought initially that this means the Java version on the Android phone is incompatible with the version the jar was compiled for. But I am less convinced of that now I think it is something else. Can anyone shed some light on this for me please?

Damien

Damien Cooke
  • 599
  • 10
  • 20

1 Answers1

0

The module-info is used only with Java 9 and up for the new "Jigsaw" module feature added with Java 9: https://www.oracle.com/corporate/features/understanding-java-9-modules.html

AFAIK Android does not yet support Java 9, but does support most, if not all, of Java 8. Does Android Studio 3 support Java 9 for Android development? If so, what features of Java 9 are supported?

You can delete the compiled file module-info.class, it doesn't need to be there when not using modules. You will find it inside the jar file javax.json.bind-api-1.0.jar, and you can remove it using any zip file or jar tool like winzip, winrar, gzip, zip, or jar.

Sean F
  • 4,344
  • 16
  • 30