NoClassDefFoundError on Android 2.1 only, using Guava Library

回眸只為那壹抹淺笑 提交于 2019-12-11 04:43:12

问题


I wrote an Android app that use the Guava library.

The app works perfectly fine on Android 4 (virtual machine and real device).

However, when I try to launch the app on a virtual machine running Android 2.1, I get the following error:

java.lang.NoClassDefFoundError: com.google.common.collect.ImmutableSortedMap

I have played with the libraries imports. The idea behind: older version of Android might handle jars in a different way. No success here.

It is worth mentioning, that the app is an update of a previous version already using Guava. The previous version worked fine on all devices, but wasn't using the ImmutableSortedMap object rather just an ImmutableList. Would it be possible that the phone is loading his own version of the Guava library (that might not contains ImmutableSortedMap)?

I am using Eclipse with ADT 20. Here is how my libraries looks like in Eclipse package explorer:

Thank you in advance!


回答1:


You probably need to be using the guava-jdk5 back port. In newer versions of Guava, ImmutableSortedMap implements NavigableMap, which was introduced in JDK6. NavigableMap is not supported in earlier versions of Android -- specifically including 2.1; NavigableMap was released on Android as of Android 2.3 Gingerbread, it looks like.

(In the backport, ImmutableSortedMap supports all the NavigableMap methods; it just doesn't actually implement NavigableMap.)



来源:https://stackoverflow.com/questions/13343488/noclassdeffounderror-on-android-2-1-only-using-guava-library

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