Pergunta

I'm getting java.lang.NoClassDefFoundError: com.google.common.collect.SortedMultisets$NavigableElementSet on Android 2.2 devices.

I'm getting the same crash on Android 2.2 emulator

I'm not getting that error on Android 4.x devices though.

My build.gradle has:

dependencies {
compile group: 'com.google.guava', name: 'guava', version: '15.0'
}

defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
}

Why is this happening?

Foi útil?

Solução

If you want to use newer version of Guava (which you should), use Guava JDK5 backport (it will work with Android 2.2). Also, see this answer explaining what's going on (some classes/interfaces Guava uses are not supported in Android 2.1-2.2).

Note that currently there's no guava-jdk5-15.0 release (and it probably won't be) but guava-jdk5-16.0 is on its way (see comments in this G+ post).

Outras dicas

I've found the answer here http://porcupineprogrammer.blogspot.com/2013/06/guava-and-minsdkversion.html.

Turns out only Guava 13 and earlier work properly with Android 2.2.

I've downgraded to Guava 13.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top