Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add desktop platform module to existing libGDX project in Android Studio?

I have created a libGDX project in Android Studio. When I first created the project, I only selected the "Android" subproject.

Here is the screenshot

Now, I have changed my mind and want to add a desktop platform module to my libGDX project in order to run the "Tools" extension. There doesn't seem to be another question asking this on stackoverflow, and that is why I am asking it. How can I achieve this?

like image 518
Shikhar Mainalee Avatar asked Dec 02 '25 05:12

Shikhar Mainalee


1 Answers

You know Project Name and package of your already generated libgdx project.

Generate another project with above details at some other place then copy the desktop folder in your old project.

Now you've to add that module in your project.

  • Add your desktop module in settings.gradle file
  • Add desktop configuration in your project build.gradle file

Done, Sync your project dependency.

EDIT

Content inside settings.gradle file should be like this :

include  'android', 'core', 'desktop'

Add below code in your project level build.gradle file

project(":desktop") {
    apply plugin: "java"


    dependencies {
        implementation project(":core")
        implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"

    }
}
like image 126
Abhishek Aryan Avatar answered Dec 04 '25 08:12

Abhishek Aryan