Guava: java.lang.NoClassDefFoundError - com.google.common.collect.HashBiMap

放肆的年华 提交于 2019-11-30 13:41:54

This error means that the class was available at compile time, but cannot be found during run time. It most commonly happens when your compile time classpath is different from your runtime classpath.

It is very likely that your runtime classpath doesn't contain the guava jar. To verify this, try printing your classpath in your code.

on the command line, you can use: java -cp "path/to/guava.jar" MyMainClass

or alternatively, set the CLASSPATH environment variable to include the jar.

In my case, I had both guava and google-collection in my library. google-collection library was conflicting with guava library. If you have both guava and google-collection, try to remove google-collection to rebuild.

I was trying to use upstream Guave 21 and 22, with sourceCompatibility JavaVersion.VERSION_1_8 enabled. This caused this error on devices below SDK version 24. The solution was to use a guave version that still supports Java 7, which was backported for Android.

dependencies {
  compile 'com.google.guava:guava:23.3-android'
}

Just download Guava library from here Guava

Clean and Build. Works for me. Hope it Helps. Cheers

In my case, I tried to add the guava-17.0.jar with the option Add External JARs... and this was the problem. When I moved the guava-17.0.jar in my projects folder (under the Libs file) I had no problem.

Of course I, removed the External JAR and add it again using the Add JARs... option

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