The Android compiler complains that Google Guava v12’s ImmutableSortedSet doesn’t have the methods, first(), last(), etc., and that ImmutableSortedSet doesn’t implement SortedSet. I am currently using Android API 8. Here’s some sample code:
/*
* I only have one set, 'mSet', but for the sake of this example
* I added an ImmutableSortedSet instance.
*/
private final SortedSet<Item> mSet;
private final ImmutableSortedSet<Item> mImmutableSet;
private MyObject(Collection <? extends Item> items) {
// Fails -- cannot convert from ImmutableSortedSet<Item> to SortedSet<Item>
mSet = ImmutableSortedSet.copyOf(items);
mImmutableSet = ImmutableSortedSet.copyOf(items);
}
private Item getFirstItem() {
// Fails -- no such method 'first()' in ImmutableSortedSet
return mImmutableSet.first();
}
UPDATE
I did a bit of digging, and it turns out NavigableSet, the interface that ImmutableSortedSet implements, only became available in API level 9 and up. I am unfortunately constrained to using API level 8. My question still stands though. Is there a way to fix this without having to play with Google’s code?
Guava 12.0 does not support your version of Android, so please stick to version 11.0.2 for now until we have a backport.