Search code examples
javaandroidnio

Bug when using CharacterBuffers in android


I am using a small compression library for short strings in java. Surprisingly when I run my application on my Nexus 7 (lollipop) it runs fine but when I run it on my ICS tab it give a noSuchMethod exception whenever I try calling CharBuffer.subSequence.

14016-14016/reach.project E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NoSuchMethodError: java.nio.CharBuffer.subSequence at reach.project.utils.MiscUtils.compress(MiscUtils.java:239)

Error on this line :

String temp = String.valueOf(charBuffer.subSequence(0, 1));

I am using JDK 7

compileOptions {
    sourceCompatibility VERSION_1_7
    targetCompatibility VERSION_1_7
}

Min SDK version 14

Any help is much appreciated.


Solution

  • It seems that this is a bug in the java compiler. Building with version 6 should resolve your problem.

    According to this link and many others.