Search code examples
javaandroideclipseclassnotfound

AbstractMap.SimpleImmutableEntry cannot be resolved to a type


I am running:

  • OS X v10.8.4
  • Eclipse 3.7.2
  • Java 1.6
  • Android minSdkVersion 17
  • Android targetSdkVersion 17

But no dice. The compiler recognizes plain old AbstractMap declarations, but has no clue about AbstractMap.SimpleEntry or AbstractMap.SimpleImmutableEntry:

bad compiler

However, via command line (javac 1.6.0_51) the following does build and run:

import java.util.AbstractMap;

public class Test {
   public static void main (String args[]) {
      AbstractMap.SimpleImmutableEntry<String, String> entry =
          new AbstractMap.SimpleImmutableEntry("key", "value");
      System.out.println(entry.getKey());
      System.out.println(entry.getValue());
   }
}

Also, Android Studio (I/O Preview) recognizes AbstractMap.SimpleImmutableEntry.

I have Build -> Clean'd, restarted Eclipse, rebooted the Mac. So something is wrong in my Eclipse setup. Help!


Solution

  • Are you sure you are building with level 17 of the SDK? AbstractMap.SimpleImmutableEntry was added in API level 9. That exact class caught me out too as I build with API level 8.