简体   繁体   English

在Android中的JavaFX项目上运行调试器

[英]Run debugger on javaFX project in android

I am trying to rebuild an old javafx project on android. 我正在尝试在android上重建一个旧的javafx项目。 Currently I am using javafxports to do so. 目前,我正在使用javafxports这样做。 The problem is I can't debug it, this is how the project hierarchy looks: 问题是我无法调试它,这是项目层次结构的外观:

在此处输入图片说明

The application is started from DisplayClient . 该应用程序从DisplayClient启动。 So far I am able to log messages using the device monitor. 到目前为止,我已经能够使用设备监视器记录消息。 Can you please tell me if it is possible to attach a debugger and if it is how? 您能否告诉我是否可以附加调试器,是否可以附加调试器? If any further information is needed I would be happy to give it. 如果需要任何进一步的信息,我很乐意提供。

You can easily attach a debugger to your IntelliJ IDE while running your app on an Android device. 在Android设备上运行应用程序时,可以轻松地将调试器连接到IntelliJ IDE。

To debug a JavaFXPorts/Gluon Mobile that you have created using the Gluon plugin for your IDE (NetBeans, IntelliJ or Eclipse), and that you have deployed to the Android device, follow these steps: 要调试使用Gluon插件为IDE(NetBeans,IntelliJ或Eclipse)创建的JavaFXPorts / Gluon Mobile,并已将其部署到Android设备,请按照以下步骤操作:

1. Create the JavaFX mobile app from your IDE 1.从您的IDE创建JavaFX移动应用程序

For that you can use the Gluon plugin for your IDE. 为此,您可以将Gluon插件用于您的IDE。 Use one of the built-in templates to create your project or go and use one of the many samples available here. 使用内置模板之一创建您的项目,或者使用此处提供的许多示例之一。

Let's say you use the Single View project. 假设您使用“单一视图”项目。 Provide a name and run the app 提供名称并运行应用程序

2. Create the apk 2.创建apk

Run the task from the Gradle View Tasks->other->AndroidInstall to create the apk (or on command line run ./gradlew android). 从Gradle View Tasks->other->AndroidInstall运行任务以创建apk(或在命令行上运行./gradlew android)。

3. Open the app on your device 3.在您的设备上打开应用

Make sure the app works on your device, and don't close it. 确保该应用可以在您的设备上运行,并且不要关闭它。

4. Open Android Device Monitor 4.打开Android设备监视器

Go to <android sdk>/tools and run monitor . 转到<android sdk>/tools并运行monitor On the left, on top you should see the device, and a list of processes. 在左侧的顶部,您应该看到该设备以及进程列表。 Find your app package name there, select it and see the port it is using for the app (8600). 在此处找到您的应用包名称,选择它,然后查看它用于该应用程序的端口(8600)。

Android显示器

5. Attach the debugger on your IDE 5.在您的IDE上附加调试器

Finally, go back to your IDE, and attach the remote debugger, with localhost and 8600 port. 最后,返回您的IDE,并使用localhost和8600端口连接远程调试器。 For the IntelliJ IDE, go to Run->Edit Configurations... , on the upper left click + , select the Remote option, and provide a name ( remote debugger ), and the port: 对于IntelliJ IDE,转到Run->Edit Configurations... ,在左上角单击+ ,选择Remote选项,并提供一个名称( remote debugger )和端口:

远程调试器

6. Run the debugger on your IDE 6.在IDE上运行调试器

Click ok to save, add some breakpoint to your code, and now run the debugger. 单击“确定”保存,在代码中添加一些断点,然后运行调试器。

In this case, I have a breakpoint in the button event handler, so when I click on it, the app halts at the breakpoint: 在这种情况下,我在按钮事件处理程序中有一个断点,因此当我单击它时,应用程序将在该断点处暂停:

调试Android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM