Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ClassNotFoundException: kotlinx.metadata.jvm.KmModuleVisitor' when using proguard option '-keepkotlinmetadata' #122

Open
adirubin opened this issue Jan 19, 2021 · 1 comment

Comments

@adirubin
Copy link

Hi,
I tried to use the plugin with the proguard option '-keepkotlinmetadata' and got this exception:

 [proguard] Exception in thread "main" java.lang.NoClassDefFoundError: kotlinx/metadata/jvm/KmModuleVisitor
 [proguard] 	at proguard.resources.kotlinmodule.io.KotlinModuleDataEntryReader.read(KotlinModuleDataEntryReader.java:49)
 [proguard] 	at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:85)
 [proguard] 	at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:85)
 [proguard] 	at proguard.io.RenamedDataEntryReader.read(RenamedDataEntryReader.java:97)
 [proguard] 	at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:85)
 [proguard] 	at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:85)
 [proguard] 	at proguard.io.JarReader.read(JarReader.java:84)
 [proguard] 	at proguard.io.DirectorySource.readFiles(DirectorySource.java:68)
 [proguard] 	at proguard.io.DirectorySource.pumpDataEntries(DirectorySource.java:54)
 [proguard] 	at proguard.InputReader.readInput(InputReader.java:262)
 [proguard] 	at proguard.InputReader.readInput(InputReader.java:230)
 [proguard] 	at proguard.InputReader.readInput(InputReader.java:207)
 [proguard] 	at proguard.InputReader.execute(InputReader.java:135)
 [proguard] 	at proguard.ProGuard.readInput(ProGuard.java:283)
 [proguard] 	at proguard.ProGuard.execute(ProGuard.java:108)
 [proguard] 	at proguard.ProGuard.main(ProGuard.java:677)
 [proguard] Caused by: java.lang.ClassNotFoundException: kotlinx.metadata.jvm.KmModuleVisitor
 [proguard] 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
 [proguard] 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
 [proguard] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

It seems that proguard's kotlin library dependencies are missing from the classpath.
According to proguard-core's gradle file, they should be:

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
    compile "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion}"
    compile "org.jetbrains.kotlinx:kotlinx-metadata-jvm:${kotlinxMetadataVersion}"
}

with these versions:
kotlinVersion = 1.3.31
kotlinxMetadataVersion = 0.1.0

Here is an example config: proguard_plugin_bug.tar.gz
To reproduce, just run mvn install

I'll be glad for a solution or a workaround.
Thanks!
Adi

@lasselindqvist
Copy link
Collaborator

I guess https://github.com/wvengen/proguard-maven-plugin/blob/master/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java#L947 does not add the transitive dependencies from proguard-core to these Kotlin dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants