Diamond type are not supported at this language level

Amir picture Amir · Mar 23, 2015 · Viewed 13.4k times · Source

After importing a project into Android studio, if I want to compile or run the project it throws an error:

Error:(61, 65) java: diamond operator is not supported in -source 1.6
(use -source 7 or higher to enable diamond operator)

Does anyone know what it is and how to solve it ?

Answer

erajuan picture erajuan · Sep 21, 2015

In Android Studio (File -> Project Structure..., Properties tab), set the following values:

Source Compatibility == 1.7
Target Compatibility == 1.7

enter image description here

After this your build.gradle will have these entries:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

enter image description here