Running and Debugging a LibGDX project

You can run and debug your projects from your IDE and command line, this article will go through the recommended ways to launch and debug your projects.


Running Desktop project in Intellij/Android Studio

Running

  • Right click your DesktopLauncher class
  • Select 'Run DesktopLauncher.main()'

    This should fail with missing assets, we need to hook up the assets folder

  • Open up Run Configurations

intellijrunconfig

  • Edit the Run Configuration that was just created by running the desktop project and set the working directory to point to your android/assets folder, or the core/assets folder if you don't have an android project

intellijworkingdir

  • Run your application using the run button

Debugging

  • Hit the Debug button instead of run after setting up the run configuration as shown above.




Running desktop project in Eclipse

Running

  • Right click your desktop project > Build Path > Configure Build Path
  • Click the sources tab, and click 'Add Folder'
  • Select the assets folder and hit OK.

eclipsebuildpath

  • Right click your desktop project > Run as > Java Application

Debugging

  • Hit the Debug button instead of run after setting up the assets folder as shown above.




Running desktop project in Netbeans

Running

  • Right click the desktop project > Run

Debugging

  • Right click the desktop project > Debug




Running Android project in Intellij/Android Studio

Running

  • Right click AndroidLauncher > Run AndroidLauncher

Debugging

  • Right click AndroidLauncher > Debug AndroidLauncher




Running Android project in Eclipse

Running

  • Right click Android project > Run As > AndroidApplication

Debugging

  • Right click Android project > Debug As > AndroidApplication




Running Android project in Netbeans

Running

  • Right click Android project > Run As > AndroidApplication

Debugging

  • Right click Android project > Debug As > AndroidApplication




Running iOS Robovm project in Intellij/Android Studio

Running

  • Open Run/Debug Configurations
  • Create a new run configuration for a RoboVM iOS application

iosrobovmrunconfig

  • Select the provisioning profile and simulator/device target
  • Run the created run configuration

For more information on using and configuring the RoboVM intellij plugin please see the documentation

NOTE: The documentation is for the 'Official' RoboVM plugin, we currently use a fork of this. This means some of the information (such as license information) is redundant, however configuring and using the plugin should be very similar.

Debugging

Debugging is not supported at this time.




Running iOS Robovm project in Eclipse

Running

  • Right click the iOS RoboVM project > Run As > RoboVM runner of your choice

robovmeclipse

For more information on using and configuring the RoboVM eclipse plugin please see the documentation

NOTE: The documentation is for the 'Official' RoboVM plugin, we currently use a fork of this. This means some of the information (such as license information) is redundant, however configuring and using the plugin should be very similar.

Debugging

Debugging is not supported at this time.




Running iOS Multi-OS Engine project in Intellij/Android Studio

Please see the official documentation for a guide to running and debugging the Multi-OS Engine Official Documentation




HTML

Html is best suited to be run on command line you are welcome to manually setup gwt in the IDE of your choice if you are familiar with it but the recommended way is to drop down to terminal or command prompt.

The html target can be run in Super Dev mode, which allows you to recompile on the fly, and debug your application in browser.

To do so, open up your favourite shell or terminal, change directory to the project directory and invoke the gradle task.

Like shown below:

On Unix based systems

cd C:/ProjectDirectoryPath/RootProjectDirectory

./gradlew html:superDev
If you get a permission denied error, set the execution flag on the gradlew file.
chmod +x gradlew

On Windows

cd C:/ProjectDirectoryPath/RootProjectDirectory

gradlew html:superDev

You should see lots of text wizzing by, and if all goes well you should see the following line at the end:

beep

You can then go to http://localhost:8080 to see your application running, with a recompile button.

For further info on configuring and debugging with SuperDev check the documentation for Super Dev

Command line running

All of the targets can be run and deployed to via the command line interface.

This is not only a helpful feature when debugging, but it also allows you to easily push your project to continuous integration, or use any number of automation tools. Its also very helpful when trying to debug an issue with a build in your IDE. It will let you know if there is a system/configuration issue instead of perhaps an IDE issue also.

Running each of the projects if very simple, just open up your shell/terminal and enter in the following commands after CDing to the root project directory.

INFO: On unix systems, use
./gradlew
on windows just use
gradlew
to invoke the Gradle tooling system.

Desktop

./gradlew desktop:run

Android

./gradlew android:installDebug android:run

iOS RoboVM

./gradlew ios:launchIPhoneSimulator

See documentation for further configuration and other tasks

iOS Multi-OS Engine

./gradlew ios-moe:moeListDevices // To list devices to provide to the next task
./gradlew ios-moemoeLaunch -Pmoe.launcher.simulators=XXXXXXXXXXXX -Pmoe.launcher.options=no-build,debug:5005

See documentation for further configuration and other tasks

HTML

./gradlew html:superDev