I am trying to use the diamond operator, but I am getting the following message:
diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
Is it fixable in netbeans with android?
I am trying to use the diamond operator, but I am getting the following message:
diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
Is it fixable in netbeans with android?
API 19 KitKat Diamonds are now allowed. Below are Gradle edits needed to implement for Android Studio. Also make sure you are using JDK 1.7 and Gradle plugin later than 0.6.1
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Android needs java source compliance 5.0 or 6.0 (Java5/6). Java7 is not supported out of the box. The're articles describing hacks on how to use some of java7 features: http://www.informit.com/articles/article.aspx?p=1966024.
Also see Java 7 language features with Android, Does Android plan to support Java7?, Can the Android SDK work with JDK 1.7?.
Android doesn't support 1.7 compilation level at this moment. So, you can't use diamond operator. You could fix this for java application by changing JRE to 1.7, but won't work with Android.
Google just released Eclipse ADT 22.6 which adds support for Java 7 language features, http://developer.android.com/tools/sdk/eclipse-adt.html