META-INF/versions/9/module-info.class: broken class file? (This feature requires ASM6)

早过忘川 提交于 2020-12-30 05:34:19

问题


I'm having issues with Bouncycastle, which only arise when running the :lint task.

Generally it seems to be a Java 9 byte-code version 53.0 / ASM version conflict.

These are the dependencies:

// https://mvnrepository.com/artifact/org.bouncycastle
implementation "org.bouncycastle:bcprov-jdk15on:1.64"
implementation "org.bouncycastle:bcpkix-jdk15on:1.64"

Which cause the :lint task to throw processing errors:

> Task :mobile:lint
Error processing bcpkix-jdk15on-1.64.jar:META-INF/versions/9/module-info.class: broken class file? (This feature requires ASM6)
Error processing bcprov-jdk15on-1.64.jar:META-INF/versions/9/module-info.class: broken class file? (This feature requires ASM6)

META-INF/versions/9/module-info.class: broken class file? (This feature requires ASM6)

Likely "broken class file" is a bogus error message, it just cannot decode module-info.class. The question is: How to provide ASM6? Since it does not happen on old versions (see my attempt at an answer), the only acceptable answer would need to be for the current version 1.64.


回答1:


As already mentioned this was introduced in Java 9, that Android does not support. You could just use packagingOptions to remove those classes.

android {
    packagingOptions {
        exclude "**/module-info.class"
    }
}

This should not affect actual executed code and should also remove classes for lint checks as lint is working on bytecode.




回答2:


When using old versions (likely built with Java 8), there are no such processing errors:

// https://mvnrepository.com/artifact/org.bouncycastle
implementation "org.bouncycastle:bcprov-jdk15on:1.60"
implementation "org.bouncycastle:bcpkix-jdk15on:1.60"

The issue obviously was introduced with version 1.61 (built with Java 9).


Deleting the versions/9/module-info.class file from both JAR works, too.

This can be automated with an Exec task, which :lint depends upon.


See https://github.com/JakeWharton/agp-java-support#readme ...
which hints for, that the bytecode transformer needs to support it.




回答3:


The file module-info.class is part of the Java module system which was introduced since Java 9. As per this issue on Android IssueTracker, the bug has been be fixed since Android Studio 3.4.




回答4:


I have got the following error message:

Error processing C:\Users\mypc\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.8.6\9180733b7df8542621dc12e21e87557e8c99b8cb\gson-2.8.6.jar:module-info.class: broken class file? (This feature requires ASM6)

This error occurs without using a development system like Android Studio. I use Gradle 6.1.1.

I prevented the mistake as follows:

  1. Open the file gson-2.8.6.jar which is named in the error message
  2. Removing of the file module-info.class, which is located in the root


来源:https://stackoverflow.com/questions/60598110/meta-inf-versions-9-module-info-class-broken-class-file-this-feature-requires

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!