Kotlin apps can't work with recent versions of Guice/Guava

Reproducing below [a ticket I just filed](https://youtrack.jetbrains.com/issue/KT-8638):

My application uses Guice 4.0 and Guava 18.0 and ./gradlew run fails with:

$ ./gradlew run
:compileKotlin UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:run
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;[Ljava/lang/Object;)V
at com.google.common.cache.CacheBuilder.setKeyStrength(CacheBuilder.java:520)
at com.google.common.cache.CacheBuilder.weakKeys(CacheBuilder.java:516)
at com.google.inject.internal.WeakKeySet.<init>(WeakKeySet.java:55)

This is happening because kotlin-compiler-0.12.1218.jar' includes com.google.comm.base.Preconditions` without shading it:

$ jar tf ~/.kobalt/repository/org/jetbrains/kotlin/kotlin-compiler/0.12.1218/kotlin-compiler-0.12.1218.jar|grep Preconditions
com/google/common/base/Preconditions.class

As a result, Kotlin apps can’t currently use recent versions of Guava or Guice.

Any suggestions?

1 Like

+1 Were there any solutions to this?

kotlin-compiler-embeddable should work