Run debugger on javaFX project in android

2020-02-16 01:55发布

问题:

I am trying to rebuild an old javafx project on android. Currently I am using javafxports to do so. The problem is I can't debug it, this is how the project hierarchy looks:

The application is started from 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.

回答1:

You can easily attach a debugger to your IntelliJ IDE while running your app on an Android device.

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:

1. Create the JavaFX mobile app from your IDE

For that you can use the Gluon plugin for your 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

Run the task from the Gradle View Tasks->other->AndroidInstall to create the apk (or on command line run ./gradlew android).

3. Open the app on your device

Make sure the app works on your device, and don't close it.

4. Open Android Device Monitor

Go to <android sdk>/tools and run 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).

5. Attach the debugger on your IDE

Finally, go back to your IDE, and attach the remote debugger, with localhost and 8600 port. 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:

6. Run the debugger on your 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: