我设法使用 gradle 和 javafxport 构建了一个 JavaFX 应用程序,但该 apk 无法安装在我的设备上。
这是我的 build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b10'
}
}
apply plugin: 'org.javafxports.jfxmobile'
mainClassName = 'java.Main'
repositories {
jcenter()
}
jfxmobile {
ios {
forceLinkClasses = ['java.**.*']
}
android {
applicationPackage = 'com.superflush.java'
androidSdk = 'C:/Users/USERNAME/AppData/Local/Android/android-sdk'
}
}
我的设备是运行库存 Android 5.0 的华硕 Zenfone2
它是 x86_64,所以我怀疑这可能是一个问题,但我不确定如何诊断。任何建议如何解决这个问题?
我设法拿到了标准 4.4.2 ARM 手机,所以它可以安装但它不会运行(黑屏),这是执行时的 logcat 错误输出:
E/DalvikLauncher(12088): java.lang.ClassNotFoundException: Didn't find class "application.Main" on path: DexPathList[[zip file "/data/app/com.superflu
sh.java-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.superflush.java-2, /vendor/lib, /system/lib]]
E/DalvikLauncher(12088): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/DalvikLauncher(12088): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
E/DalvikLauncher(12088): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
E/DalvikLauncher(12088): at javafxports.android.DalvikLauncher.resolveApplicationClass(DalvikLauncher.java:232)
E/DalvikLauncher(12088): at javafxports.android.DalvikLauncher.launchApp(DalvikLauncher.java:134)
E/DalvikLauncher(12088): at javafxports.android.FXDalvikEntity.getLauncherAndLaunchApplication(FXDalvikEntity.java:118)
E/DalvikLauncher(12088): at javafxports.android.FXDalvikEntity.surfaceCreated(FXDalvikEntity.java:144)
E/DalvikLauncher(12088): at android.view.SurfaceView.updateWindow(SurfaceView.java:572)
E/DalvikLauncher(12088): at android.view.SurfaceView.access$000(SurfaceView.java:86)
E/DalvikLauncher(12088): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
E/DalvikLauncher(12088): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
E/DalvikLauncher(12088): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1871)
E/DalvikLauncher(12088): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
E/DalvikLauncher(12088): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
E/DalvikLauncher(12088): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
E/DalvikLauncher(12088): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
E/DalvikLauncher(12088): at android.view.Choreographer.doFrame(Choreographer.java:544)
E/DalvikLauncher(12088): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
E/DalvikLauncher(12088): at android.os.Handler.handleCallback(Handler.java:733)
E/DalvikLauncher(12088): at android.os.Handler.dispatchMessage(Handler.java:95)
E/DalvikLauncher(12088): at android.os.Looper.loop(Looper.java:136)
E/DalvikLauncher(12088): at android.app.ActivityThread.main(ActivityThread.java:5149)
E/DalvikLauncher(12088): at java.lang.reflect.Method.invokeNative(Native Method)
E/DalvikLauncher(12088): at java.lang.reflect.Method.invoke(Method.java:515)
E/DalvikLauncher(12088): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/DalvikLauncher(12088): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
E/DalvikLauncher(12088): at dalvik.system.NativeStart.main(Native Method)
这是我的项目结构,Main.java 是主要的: