META-INF/version duplicate error when using Proguard

Gradle : 4.10.1
Gradle Android Plugin version : 3.3.2
Proguard : 6.0.3
JDK - 1.9
Android Studio 3.3.2
When I try to build apk release version along with Proguard. I get the following error -

Caused by: Please correct the above warnings first.
	at proguard.InputReader.execute(
	at proguard.ProGuard.readInput(
	at proguard.ProGuard.execute(

This seems to be caused due to this -

Warning: class [META-INF/versions/9/module-info.class] unexpectedly contains class [module-info]
Note: duplicate definition of program class [module-info]
Note: there were 20 duplicate class definitions.
Warning: there were 21 classes in incorrectly named files.
         You should make sure all file names correspond to their class names.
         The directory hierarchies must correspond to the package hierarchies.

From extensive searching it looks like Proguard has a problem with META-INF/versions/9. I have multiple dependencies that contain this.

While the issue to seems to somewhat documented, no solutions prescribed seem to work.
suggests filtering out those class files via -

-injars my_lib.jar(!META-INF/versions/**.class)

However when I try this it just labels more files as duplicate and incorrectly named. I also tried excluding it via gradle-

packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/versions'
        exclude 'META-INF/versions/9/module-info.class'

This also fails to resolve the problem. How do I solve this problem ?

1 Like

Did you ever figure this out? I’m dealing with the same problem after adding a dynamic feature module. Only with proguard and/or R8 implemented.

I have run into the same issue:
Gradle : 5.4.1
Gradle Android Plugin version : 3.5.3
Proguard : 6.0.3
JDK - 1.8
Android Studio: 3.5.3

I added the following to my proguard file and the build works and from what I can tell no side effects in code:

-dontwarn module-info

I’m not very good with proguard so I’m not sure if/how this impacts other things.