Shikhar Mainalee
Shikhar Mainalee

Reputation: 221

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?

Upvotes: 3

Views: 1301

Answers (2)

AAryan
AAryan

Reputation: 20140

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"

    }
}

Upvotes: 3

I know this may not be what you are looking for but what I would do is generate another LibGDX project with the Project Setup app with desktop checked and copy-paste all my code into this new project, optionally, if you want the new project to have the same name rename previous as "previous-backup" Remember to add a desktop configuration, here's a example from one of my projects: what's in red is just my project specific paths

Upvotes: 0

Related Questions