我目前尝试结合以下技术:
- 胶子(移动)
- Gradle(Gluon的依赖,因为他们依赖它)
- Kotlin(因为它是我想深入研究的一门很好的语言)
- Tornado FX(我猜是 JavaFX 的,Anko 是 Android 的)
问题是,我对 Intellij-IDEA 比较陌生,并且在正确设置它时遇到了问题,尽管我认为该build.gradle
文件足够合适。
这是我build.gradle
到目前为止的样子:
buildscript {
ext.kotlin_version = '1.0.6'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'kotlin'
// apply plugin: 'com.android.application'
// apply plugin: 'kotlin-android'
repositories {
jcenter()
mavenCentral()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'eu.dzim.test.Main'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile 'com.gluonhq:charm:4.2.0'
compile 'no.tornado:tornadofx:1.5.9'
compile 'no.tornado:tornadofx-controls:1.0.4'
}
jfxmobile {
downConfig {
version = '3.1.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'
}
}
我至少设法阻止 IDE 抱怨 Kotlin。我将一个简单的应用程序类转换为如下所示:
package eu.dzim.test
import com.gluonhq.charm.down.Platform
import javafx.application.Application
import javafx.scene.Scene
import javafx.scene.layout.BorderPane
import javafx.stage.Screen
import javafx.stage.Stage
/**
* Created by daniel on 06.01.17.
*/
class Main : Application() {
@Throws(Exception::class)
override fun start(stage: Stage) {
var width = -1.0
var height = -1.0
if (Platform.isDesktop()) {
width = 480.0
height = 640.0
stage.title = "Test"
}
val primaryScreen = Screen.getPrimary()
val visualBounds = primaryScreen.visualBounds
if (width < 0 || height < 0) {
width = visualBounds.width
height = visualBounds.height
}
val root = BorderPane()
val scene = Scene(root, width, height)
stage.scene = scene
stage.show()
}
}
但现在我被困住了,因为对 Tornado FX 的依赖没有得到正确解决。我想创建一个View
并开始
package eu.dzim.test
import tornadofx.View
import tornadofx.borderpane
class Root : View("My View") {
override val root = borderpane {
}
}
但是像这样的进口import tornadofx.View
永远不会得到解决。
有问题吗,因为 Tornado 似乎使用 Kotlin 1.0.5
,而我想使用1.0.6
?(虽然这没有效果,但如果我改变它,关于(仍然未使用,因为“未解决”)View
......)
问候,丹尼尔