2

I primarily use LibGDX to develop games for Android. It is helpful to test on the desktop. When I do so, I just set the "desktop" project in Android Studio to use the assets from the "android" project, as described here. This works great on my local machine for testing purposes. However, it won't work if I want to package my game and release it for other's to play on their own machines. How do I go about packaging my game to include the graphic and audio assets?

Community
  • 1
  • 1
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268

1 Answers1

1

I stumbled on the following snippet in the build.gradle file:

task dist(type: Jar) {
    from files(sourceSets.main.output.classesDir)
    from files(sourceSets.main.output.resourcesDir)
    from {configurations.compile.collect {zipTree(it)}}
    from files(project.assetsDir);

    manifest {
        attributes 'Main-Class': project.mainClassName
    }
}

This appears to bundle project.assetsDir into the JAR file created by the dist task which is set as

project.ext.assetsDir = new File("../android/assets");

To run the above task from the command line, type

gradlew desktop:dist
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268