简体   繁体   中英

NoClassDefFoundError on Android 2.1 only, using Guava Library

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:

Eclipse软件包浏览器。

Thank you in advance!

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 .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM