我无法在我的 Android 手机上使用简单的 Sphere 或 MeshView 等 Shape3D 对象。我已经使用 NetBeans 8.0.2 的 Gluon 插件为我的手机创建小应用程序,这是我第一次使用 Shape3D 对象。
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Sphere;
import javafx.stage.Screen;
import javafx.stage.Stage;
public class testGluonApp extends Application {
@Override
public void start(Stage stage) throws Exception {
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
Sphere sphere = new Sphere(64.0);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(sphere);
Scene scene = new Scene(stackPane, visualBounds.getWidth(), visualBounds.getHeight());
stage.setScene(scene);
stage.show();
}
}
上面的示例应用程序(来自 javafxports 示例)在我的 PC 上运行良好,但是当我编译应用程序 (Tasks->android->android) 并将其安装到我的设备 (Tasks->android->androidInstall) 时,它会安装但在启动时只显示黑屏。
I HwLauncher: FPSMonitor [Launcher , dispatchTouchEvent begin, false, true] down event x = 697 y = 697
I HwLauncher: FPSMonitor [PagedView , onIntercept] down event x = 697 y = 697
I HwLauncher: FPSMonitor [Launcher , dispatchTouchEvent end, false, true] down event x = 697 y = 697
I HwLauncher: FPSMonitor [Launcher , dispatchTouchEvent begin, false, true] up event x = 697 y = 697
I HwLauncher: FPSMonitor snapToPage whichPage = 2 delta = -1 duration = 550
I HwLauncher: FPSMonitor [PagedView , onIntercept] up event x = 697 y = 697
I HwLauncher: FPSMonitor [Launcher , dispatchTouchEvent end, false, true] up event x = 697 y = 697
W ResourceType: No known package when getting name for resource number 0x9c020200
I HwLauncher: Launcher onclick begin com.huawei.android.launcher.BubbleTextView{39e53f77 VFED..CL ...P.... 528,120-792,399 #9c020200}
I HwLauncher: Launcher.Utilities startActivitySafely useLaunchAnimation begin startActivity()
I K3V3CpuGovernorPolicy: set scene Hmp policy : 300 , 150
I HwLauncher: Launcher.Utilities startActivitySafely useLaunchAnimation end startActivity()
I HwLauncher: Launcher onclick end
I HwLauncher: Launcher onPause()
I HwLauncher: Launcher.MotionManager stopMotionAppsReco 402
I HwLauncher: Launcher.MotionManager stopMotionAppsReco 403
W HwLauncher: Launcher.MotionManager stopMotionAppsReco service flg 402 is unavailable
W HwLauncher: Launcher.MotionManager stopMotionAppsReco service flg 403 is unavailable
I art : Late-enabling -Xcheck:jni
I View : ssignParent(ViewParent parent) parent is: android.view.ViewRootImpl@26e8f389
I [Gralloc]: alloc w[1080] h[1920] format[1] usage[2355]
I [Gralloc]: alloc succ handle[0xb80a6778] stride[1120]
I [Gralloc]: alloc w[1080] h[1920] format[1] usage[3]
I [Gralloc]: alloc succ handle[0xb8044e70] stride[1120]
I HwLauncher: Launcher onStop()
I HwLauncher: Launcher dismissDialog
I HwLauncher: Launcher dismissDialog
I HwLauncher: Launcher dynamicIconsUnregister
I HwLauncher: DynamicUpdater unregisterReceiver
I PhoneStatusBar: shouldTranslucent:true
I PhoneStatusBar: hw_status_bar_operators = true, setSystemUIVisibily(SHOW_OPERATOR = false)
I HwLauncher: DynamicIcon onPause isvisible = true mAttachedToWindow:true mWindowVisible:truecom.android.deskclock
I HwLauncher: DynamicUpdater unregisterReceiver
I HwLauncher: DynamicIcon onPause isvisible = true mAttachedToWindow:true mWindowVisible:truecom.android.calendar
I HwLauncher: DynamicUpdater unregisterReceiver
I HwSystemManager: AppLockService:applock password not initial or function is closed
I HwLauncher: DynamicIcon onPause isvisible = true mAttachedToWindow:false mWindowVisible:falsecom.huawei.android.totemweather
I HwLauncher: DynamicIcon onVisibilityChanged 4 - com.android.deskclock
I HwLauncher: DynamicIcon onVisibilityChanged 4 - com.android.calendar
I HwLauncher: Launcher onWindowVisibilityChanged visibility = 8
I HwLauncher: DynamicIcon onWindowVisibilityChanged 8 - com.android.deskclock
I HwLauncher: DynamicIcon onWindowVisibilityChanged 8 - com.android.calendar
I HwSystemManager: AppLockService:applock password not initial or function is closed
I HwSystemManager: AppManager:getNetAppInfoFromDB cursor lenth = 1
I MultiDex: VM with version 2.1.0 has multidex support
I MultiDex: install
I MultiDex: VM has multidex support, MultiDex support library is disabled.
I HwCust : Constructor found for class android.app.HwCustApplicationPackageManagerImpl
I CachedDir: file changed, refill cache - 1357
W PG Utils: set mRatioMinBrightness to default value for other product
W PG Utils: mRatioMinBrightness = 35
W PGApi_client: recv actoionId = 10000, action = com.huawei.pgmng.PGAction@1188d995 actionId =10000 pkg =com.gluonapplication3 extend1 =1907 extend2 = flag =3 type =1
I AudioEffectLowPowerImpl: handle default mActionId = 10000, action = com.huawei.pgmng.PGAction@1188d995 actionId =10000 pkg =com.gluonapplication3 extend1 =1907 extend2 = flag =3 type =1
I View : ssignParent(ViewParent parent) parent is: android.view.ViewRootImpl@3cb24db8
I OpenGLRenderer: Initialized EGL, version 1.4
I [Gralloc]: alloc w[1080] h[1920] format[1] usage[2816]
I [Gralloc]: alloc succ handle[0xb8058cc8] stride[1120]
I [Gralloc]: alloc w[1080] h[1920] format[1] usage[2816]
I [Gralloc]: alloc succ handle[0xb81e4ec0] stride[1120]
I [Gralloc]: alloc w[1080] h[1920] format[1] usage[2816]
I [Gralloc]: alloc succ handle[0xb8006808] stride[1120]
I System.out: javax.xml.stream.XMLEventFactory=com.sun.xml.stream.events.ZephyrEvent...
I System.out: prism.text=native
I System.out: java.vendor.url=http://www.android.com/
I System.out: java.ext.dirs=
I System.out: line.separator=
I System.out: file.encoding=UTF-8
I System.out: java.runtime.version=0.9
I System.out: prism.dirtyopts=true
I System.out: user.name=root
I System.out: java.compiler=
I System.out: android.icu.unicode.version=6.3
I System.out: javax.xml.stream.XMLOutputFactory=com.sun.xml.stream.ZephyrWriterFactory
I System.out: prism.debugfonts=true
I System.out: com.sun.javafx.gestures.rotate=true
I System.out: java.version=0
I System.out: android.icu.library.version=53.1.0.1
I System.out: use.egl=true
I System.out: embedded=monocle
I System.out: com.sun.javafx.gestures.scroll=true
I System.out: prism.lcdtext=false
I System.out: os.arch=armv7l
I System.out: java.io.tmpdir=/data/data/com.gluonapplication3/cache
I System.out: glass.platform=Monocle
I System.out: android.zlib.version=1.2.8
I System.out: user.language=fi
I System.out: java.vm.version=2.1.0
I System.out: com.sun.javafx.isEmbedded=true
I System.out: javax.xml.stream.XMLInputFactory=com.sun.xml.stream.ZephyrParserFactory
I System.out: prism.glDepthSize=16
I System.out: path.separator=:
I System.out: java.runtime.name=Android Runtime
I System.out: java.specification.version=0.9
I System.out: user.dir=/
I System.out: prism.maxTextureSize=2048
I System.out: java.vm.specification.vendor=The Android Project
I System.out: com.sun.javafx.gestures.zoom=true
I System.out: java.vm.name=Dalvik
I System.out: log.lens=FINEST
I System.out: java.vm.specification.version=0.9
I System.out: user.home=
I System.out: java.specification.name=Dalvik Core Library
I System.out: file.separator=/
I System.out: java.library.path=/vendor/lib:/system/lib
I System.out: user.variant=
I System.out: os.version=3.10.74-gc69e6c2
I System.out: java.boot.class.path=/system/framework/core-libart.jar:/sy...
I System.out: DALVIK.prism.verbose=true
I System.out: java.vm.specification.name=Dalvik Virtual Machine Specification
I System.out: javafx.platform=android
I System.out: glass.lens=eglfb
I System.out: user.region=FI
I System.out: os.name=Linux
I System.out: java.class.path=.
I System.out: prism.verbose=true
I System.out: prism.vsync=false
I System.out: java.specification.vendor=The Android Project
I System.out: java.vm.vendor=The Android Project
I System.out: prism.allowhidpi=true
I System.out: java.vendor=The Android Project
I System.out: http.agent=Dalvik/2.1.0 (Linux; U; Android 5.1.1...
I System.out: android.icu.cldr.version=25.0
I System.out: android.openssl.version=OpenSSL 1.0.1k 8 Jan 2015
I System.out: java.home=/system
I System.out: java.vm.vendor.url=http://www.android.com/
I System.out: java.class.version=50.0
I System.out: Prism pipeline init order: es2
I System.out: Using native-based Pisces rasterizer
I System.out: Using dirty region optimizations
I System.out: Using system sized mask for primitives
I System.out: Not forcing power of 2 sizes for textures
I System.out: Using hardware CLAMP_TO_ZERO mode
I System.out: Opting in for HiDPI pixel scaling
I System.out: Prism pipeline name = com.sun.prism.es2.ES2Pipeline
I System.out: Loading ES2 native library ... prism_es2_monocle
E art : dlopen("/vendor/lib/libprism_es2_monocle.so", RTLD_LAZY) failed: dlopen failed: library "/vendor/lib/libprism_es2_monocle.so" not found
E art : dlopen("/system/lib/libprism_es2_monocle.so", RTLD_LAZY) failed: dlopen failed: library "/system/lib/libprism_es2_monocle.so" not found
I System.out: succeeded.
I System.out: GLFactory using com.sun.prism.es2.MonocleGLFactory
E art : dlopen("/vendor/lib/libglass_monocle.so", RTLD_LAZY) failed: dlopen failed: library "/vendor/lib/libglass_monocle.so" not found
E art : dlopen("/system/lib/libglass_monocle.so", RTLD_LAZY) failed: dlopen failed: library "/system/lib/libglass_monocle.so" not found
I GLASS : I have to Call dlopen libGLESv2.so
I GLASS : handle = 0xb6c87004
I GLASS : I have to Call dlopen libEGL.so
I GLASS : handle = 0xb6f01bd4
I GLASS : Binding to libactivity.so
I GLASS : GetNativeWindow = 0xb3c68d05, getDensitiy = 0xb3c68d11
I System.out: (X) Got class = class com.sun.prism.es2.ES2Pipeline
I System.out: Initialized prism pipeline: com.sun.prism.es2.ES2Pipeline
I View : ssignParent(ViewParent parent) parent is: null
I ActivityManager: Displayed com.gluonapplication3/javafxports.android.FXActivity: +514ms
I View : ssignParent(ViewParent parent) parent is: null
I DENSITY : GETDENSITY, answer = 3.000000
I System.out: Maximum supported texture size: 8192
I System.out: Maximum texture size clamped to 2048
I System.out: Non power of two texture support = true
I System.out: Maximum number of vertex attributes = 16
I System.out: Maximum number of uniform vertex components = 4096
I System.out: Maximum number of uniform fragment components = 4096
I System.out: Maximum number of varying components = 60
I System.out: Maximum number of texture units usable in a vertex shader = 16
I System.out: Maximum number of texture units usable in a fragment shader = 16
I System.out: Graphics Vendor: ARM
I System.out: Renderer: Mali-T624
I System.out: Version: OpenGL ES 3.1
I System.out: register device done
W System.err: vsync: false vpipe: true
I System.out: [MON] Create device
I System.out: [MON] Create device done, add done
E art : dlopen("/vendor/lib/libjavafx_font.so", RTLD_LAZY) failed: dlopen failed: library "/vendor/lib/libjavafx_font.so" not found
E art : dlopen("/system/lib/libjavafx_font.so", RTLD_LAZY) failed: dlopen failed: library "/system/lib/libjavafx_font.so" not found
W System.err: Loading FontFactory com.sun.javafx.font.freetype.FTFactory
W System.err: Subpixel: enabled
E art : dlopen("/vendor/lib/libjavafx_font_freetype.so", RTLD_LAZY) failed: dlopen failed: library "/vendor/lib/libjavafx_font_freetype.so" not found
E art : dlopen("/system/lib/libjavafx_font_freetype.so", RTLD_LAZY) failed: dlopen failed: library "/system/lib/libjavafx_font_freetype.so" not found
W System.err: Freetype2 Loaded (version 2.5.0)
W System.err: LCD support Enabled
W art : Before Android 4.1, method void com.sun.javafx.scene.transform.TransformUtils$ImmutableTransform.ensureCanTransform2DPoint() would have incorrectly overridden the package-private method in javafx.scene.transform.Transform
W javafx.scene.Scene: System can't support antiAliasing
E javafx : Shader compile log: 0:79: P0001: Extension directive must occur before any non-preprocessor tokens
E javafx : 0:138: P0001: Extension directive must occur before any non-preprocessor tokens
E javafx : 0:194: P0001: Extension directive must occur before any non-preprocessor tokens
E javafx : 0:250: P0001: Extension directive must occur before any non-preprocessor tokens
E javafx :
W System.err: java.lang.RuntimeException: Error creating fragment shader
W System.err: at com.sun.prism.es2.ES2Shader.createFromSource(ES2Shader.java:141)
W System.err: at com.sun.prism.es2.ES2PhongShader.getShader(ES2PhongShader.java:177)
W System.err: at com.sun.prism.es2.ES2Context.getPhongShader(ES2Context.java:122)
W System.err: at com.sun.prism.es2.ES2Context.renderMeshView(ES2Context.java:451)
W System.err: at com.sun.prism.es2.ES2MeshView.render(ES2MeshView.java:119)
W System.err: at com.sun.javafx.sg.prism.NGShape3D.renderMeshView(NGShape3D.java:179)
W System.err: at com.sun.javafx.sg.prism.NGShape3D.renderContent(NGShape3D.java:201)
W System.err: at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2053)
W System.err: at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
W System.err: at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:235)
W System.err: at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:576)
W System.err: at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2053)
W System.err: at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
W System.err: at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:477)
W System.err: at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:330)
W System.err: at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
W System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
W System.err: at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:279)
W System.err: at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W System.err: at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
W System.err: at java.lang.Thread.run(Thread.java:831)
I K3V3CpuGovernorPolicy: close previously scene Hmp policy : 300 , 150
I MQoS : MSG_QUERY_TCP_INFO called,count:2174
这是我从 adb logcat 得到的(感谢您提供如何从设备获取它的说明)。我不知道如何解决这个问题。我找不到任何涉及着色器的方法或任何有关 Shape3D 对象着色器的信息,这似乎是导致问题的原因。
我注意到示例程序的 build.gradle 默认具有“jfxmobile-plugin:1.0.6”。我将其更改为 1.0.7,但问题仍然存在。 “主”项目一直在 build.gradle 中有 1.0.7。由于更改为 1.0.7 而发生更改,因此更新了新的堆栈跟踪。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.7'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
}
mainClassName = 'com.gluonapplication3.GluonApplication3'
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'dirHavingSDK/AndroidSDK'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
最佳答案
JavaFX3D 使用 JavaFXPorts 在 Android 上运行,如您所见here .
如果发现黑屏,首先需要找出可能的原因。通常,根据设备的类型,内存可能是个问题。
将手机连接到 PC 并启用调试选项(转到“设置”、“开发人员选项”、设置启用 USB 调试),转到命令行并运行:
adb logcat -v threadtime
现在运行您的应用并尝试在输出中查找异常。
如果你碰巧发现了一个java.lang.StackOverflowError
检查这个answer如需解决方案,请应用并重试。
您可能会发现的其他问题是您的设备不支持 3D 条件功能。
对于其他情况,请尝试解决或发布相关部分以便我们提供帮助。
编辑
根据 OP 发布的堆栈跟踪,异常显示了从 Android 5.1.1 更新到 6.0 时报告的问题,因为 Android 上的最新驱动程序在编译着色器方面更加严格。
已经创建了针对此问题的修复程序 here ,并将随 javafxports 版本 8.60.7 提供。
关于JavaFX Shape3D 对象不适用于 Android 手机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35108591/