如何更改科尔多瓦子项目用java版本 [英] How to change java version used by cordova subprojects
问题描述
我有一个科尔多瓦项目,我建立一个Android插件吧。我的插件然后使用该使用金刚石操作(小于>)的库。我试图运行它,但我收到此错误:
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)
当我运行:
$ 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
我之前发布的研究和一些人通过改变蚂蚁解析 config.xml中
到
<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />
但它没有为我工作。
But it didnt worked for me.
我也试过做一个集结额外gradle这个
文件来设置了 sourceCompatibility
和 targetCompatibility
,但它只是似乎解决了主体工程,不是我的我的插件使用子项目。
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.
推荐答案
好吧,什么对我来说是将所有你插件子项目(库)曾使用的YOUT科尔多瓦项目的主库。
Okay, what worked for me was adding all the sub-projects(libraries) that you plugin uses as main-libraries of yout cordova project.
下面我做了什么:
复制所有的库库,去日食>构建路径>订单和出口>标记的一切。
在这之后,你必须创建你的根/平台/ android文件夹,一个构建extras.gradle文件。将这个code对您的文件:
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.).
这篇关于如何更改科尔多瓦子项目用java版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!