我可以在Gluon Mobile上使用最新的Java 8支持吗?
问题描述:
谷歌几个月前发布了Android API级别为24以上的Java 8支持的gradle插件。这是通过添加依赖到gradle构建文件实现的:我可以在Gluon Mobile上使用最新的Java 8支持吗?
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha7'
}
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
这是否支持Gluon Mobile?
答
我已经安装了构建工具25.0.3,没有在所有的build.gradle
文件胶子插件生成一个单一视图项目的任何修改:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.8'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonandroid24.GluonAndroid24'
dependencies {
compile 'com.gluonhq:charm:4.3.7'
}
jfxmobile {
downConfig {
version = '3.6.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
我可以包括Java的8流:
public BasicView(String name) {
super(name);
Label label = new Label("Hello JavaFX World!");
Button button = new Button("Change the World!");
button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE));
button.setOnAction(e -> label.setText("Sum: " + Stream.of("1", "2", "5")
.mapToInt(Integer::parseInt)
.sum()));
VBox controls = new VBox(15.0, label, button);
controls.setAlignment(Pos.CENTER);
controls.getChildren().stream()
.filter(Label.class::isInstance)
.forEach(System.out::println);
setCenter(controls);
}
并在桌面上运行该项目,并在Android上成功运行它(至少在我的设备上使用Android 7.1.1)。显然不是在iOS上。
jfxmobile插件已经寻找您安装在$ AndroidSdk/build-tools中的最新生成工具版本。如果你想设置一些选项,你可以设置:
jfxmobile {
...
android {
manifest = 'src/android/AndroidManifest.xml'
buildToolsVersion = '25.0.3'
compileSdkVersion = '25'
minSdkVersion = '25'
targetSdkVersion = '25'
}
}
我明白了,谢谢。顺便说一句,gluon plugin和eclipse(带Buildship)有一个问题,它不会让你完成新的项目向导。有人发布它[这里](https://stackoverflow.com/questions/42953287/eclipse-gluon-new-project-does-not-finish)所以如果问题是胶子方面,也许你应该报告它。 – Mark
谢谢,这是一个已知的问题:新的Buildship 2+打破了Buildship 1.0。+的兼容性,这是与插件捆绑在一起的。它已经被报道。现在的解决方案是回到Buildship 1。 –