无法找到或加载主类 - 在Android上使用javafx移动插件

时间:2022-11-18 17:01:37

I was able to build/compile my project using javafxmobileplugin.The command I used was "gradlew androidInstall". I was able to install the apk in my device, but while launching a blank screen appears. On the terminal, I could see the error "Could not find or load main class".Please help.

我能够使用javafxmobileplugin构建/编译我的项目。我使用的命令是“gradlew androidInstall”。我能够在我的设备中安装apk,但是在启动时会出现一个空白屏幕。在终端上,我可以看到错误“无法找到或加载主类”。请帮助。

My build.gradle is as follow:

我的build.gradle如下:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b7'
    }
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'application'
mainClassName = 'ch.nest.application.Main'



    repositories {
        jcenter()
    }

jfxmobile {
    android {
        applicationPackage = 'ch.nest.application'
    }
}

sourceSets {
    main {
//            manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src/main/java/']
//            resources.srcDirs = ['src']
//            aidl.srcDirs = ['src']
//            renderscript.srcDirs = ['src']
//            res.srcDirs = ['res']
//            assets.srcDirs = ['assets']
    }
}
project(':app') {
    preloaderClassName = "ch.nest.application.Main"
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.2.1'
}

1 个解决方案

#1


Have you tried the Gluon-plugin for NetBeans?

您是否尝试过NetBeans的Gluon插件?

You can create a new JavaFX project with it, and it will create for you all the folders (main, desktop, android, ios) and a build.gradle file.

您可以使用它创建一个新的JavaFX项目,它将为您创建所有文件夹(main,desktop,android,ios)和build.gradle文件。

You just need to update the jfxmobile plugin version to 1.0.0-b8 (you could use b9-SNAPSHOT for very last changes).

您只需要将jfxmobile插件版本更新为1.0.0-b8(您可以使用b9-SNAPSHOT进行最后的更改)。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b8'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
}

mainClassName = 'ch.nest.application.Main'

jfxmobile {
    ios {
        forceLinkClasses = [ 'ch.nest.application.**.*' ]
    }
}

You can build and test this on your desktop, or run any ot the tasks like androidInstall to test it on your mobile.

您可以在桌面上构建和测试它,或运行任何类似androidInstall的任务来在您的手机上测试它。

Once you have tested it, just provide the full code to the respective packages and try it again.

测试完成后,只需将相应的软件包提供给相应的软件包,然后再次尝试。

#1


Have you tried the Gluon-plugin for NetBeans?

您是否尝试过NetBeans的Gluon插件?

You can create a new JavaFX project with it, and it will create for you all the folders (main, desktop, android, ios) and a build.gradle file.

您可以使用它创建一个新的JavaFX项目,它将为您创建所有文件夹(main,desktop,android,ios)和build.gradle文件。

You just need to update the jfxmobile plugin version to 1.0.0-b8 (you could use b9-SNAPSHOT for very last changes).

您只需要将jfxmobile插件版本更新为1.0.0-b8(您可以使用b9-SNAPSHOT进行最后的更改)。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b8'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
}

mainClassName = 'ch.nest.application.Main'

jfxmobile {
    ios {
        forceLinkClasses = [ 'ch.nest.application.**.*' ]
    }
}

You can build and test this on your desktop, or run any ot the tasks like androidInstall to test it on your mobile.

您可以在桌面上构建和测试它,或运行任何类似androidInstall的任务来在您的手机上测试它。

Once you have tested it, just provide the full code to the respective packages and try it again.

测试完成后,只需将相应的软件包提供给相应的软件包,然后再次尝试。