Skip to content

Android compile error #16

Closed
Closed

Description

@tapir

Although I can work with ipaddress outside of an android project, when I'm trying in one I get this error

ipaddress-5.0.1.jar: D8: Illegal class file: Class module-info is missing a super type.

Any ideas?

Activity

  1. seancfoley commented on Jan 8, 2019

    @seancfoley
    Owner

    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

    I added that file only for those who wished to use Java 9 modules. Using modules is somewhat optional (you can choose to put everything in the default module).

    AFAIK Android does not yet support Java 9, but does support most, if not all, of Java 8. Certainly, it sounds like your android version does not support Java 9 modules.
    https://stackoverflow.com/questions/47627499/does-android-studio-3-support-java-9-for-android-development-if-so-what-featur

    So you can just delete that source file module-info.java, and you can delete the compiled file module-info.class, it doesn't need to be there when not using modules.

  2. seancfoley commented on Jan 8, 2019

    @seancfoley
    Owner

    Perhaps I will add another jar file that does not have module-info inside. In reality the file should be ignored when not using modules but I guess your android environment is not ignoring it. You can just use any zip-file tool (winzip, gzip, winrar, zip, etc) to remove the module-info class file from your jar file (a jar file is actually a zip file).

  3. tapir commented on Jan 8, 2019

    @tapir
    Author
  4. seancfoley commented on Jan 8, 2019

    @seancfoley
    Owner

    OK, seems you are not the first to encounter this.
    Azure/azure-iot-sdk-java#302
    Fazecast/jSerialComm#128
    Azure/azure-iot-sdk-java#313
    JodaOrg/joda-money#94
    Leanplum/Leanplum-Android-SDK#251

    Not sure if anyone found a nice solution in any of those other issues.

    I'll have to give this a little thought.

  5. seancfoley commented on Jan 9, 2019

    @seancfoley
    Owner

    @tapir Strangely, there appear to be no simple solution from any of Maven, Android Studio, Java, or Gradle, although eventually Android Studio will likely have some kind of fix.

    From what I can tell, what others have done:

    1. put separate jar on maven just for android, which seems like a lot of extra overhead just to delete a single small file

    2. there appears to be a jarjar tool some have used, such as in that fazecast bug above Android studio build failed Fazecast/jSerialComm#128 (comment)
      and here https://stackoverflow.com/questions/44913406/exclude-one-class-file-in-gradle-android-studio
      This appears to be the tool: https://github.com/shevek/jarjar
      Looks like you would need something like this:

       dependencies {
       	// Use jarjar.repackage in place of a dependency notation.
       	compile jarjar.repackage {
       		from 'com.github.seancfoley:ipaddress:5.0.1'
      
       		classDelete "module-info"
       	}
       }
      

    Not sure if you would need "module-info" or "module-info.class"

    There is a complete example build file here: https://github.com/shevek/jarjar/blob/master/jarjar-gradle/example/build.gradle
    Can you try this second option?

  6. tapir commented on Jan 9, 2019

    @tapir
    Author

    looks like a good solution to me. thanks

  7. seancfoley commented on Jan 9, 2019

    @seancfoley
    Owner

    @tapir Have you tried it? If and when you try it, can you let me know if it works?

  8. tapir commented on Jan 9, 2019

    @tapir
    Author

    Sorry it took a while. Most of the time I've spent went to solve how to apply gradle plugins. TL,DR: It works.
    I consider this issue solved.

  9. seancfoley commented on Jan 9, 2019

    @seancfoley
    Owner

    @tapir Great! Good to know it works. Also, keep in mind Android Studio will almost certainly have its own fix eventually.

  10. seancfoley commented on Jan 6, 2020

    @seancfoley
    Owner

    This appears to have been fixed in Android Studio 3.3

    Processing module-info.class during desugaring analysis caused failures with the message java.lang.IllegalArgumentException: Type without superclass: module-info. This file is now filtered out during desugaring analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions