Search code examples
androidandroid-studiodiamond-operator

Diamond type are not supported at this language level


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 ?


Solution

  • 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