I have a Cordova project, and I am building a android plugin for it. My plugin then uses a library that uses the diamond operation (<>). I tried to run it but I receive this error :
diamond operator is not supported in -source 1.6
ArrayList<Node> selectedProviders = new ArrayList<>();
^
(use -source 7 or higher to enable diamond operator)
When I run:
$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
$ javac -version
javac 1.7.0_67
I research before posting and some people resolved by changing the ant config.xml
to
<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />
But it didnt worked for me.
I also tried make a build-extra-gradle
file to set-up the sourceCompatibility
and targetCompatibility
, but it just appears to resolve the main project, not the subproject that I use on my plugin.
Okay, what worked for me was adding all the sub-projects(libraries) that you plugin uses as main-libraries of yout cordova project.
Here what I did: Copy all the libraries to libs, go to eclipse>build path>order and export>Mark everything. After that, you have to create a build-extras.gradle file on your root/platforms/android folder. Put this code on your file:
ext.postBuildExtras = {
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
allprojects {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
}
}
Keeping referencing in the subprojects, though. You have to make the reference from the project and the subproject (not sure why, but worked.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With