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?
Asked
Active
Viewed 1,060 times
2
-
Here is the official step-by-step guide: https://github.com/libgdx/libgdx/wiki/Deploying-your-application#deploy-to-windowslinuxmac-os-x – Mikhail Churbanov Oct 27 '16 at 22:18
-
@Rinold Thanks for the link. Looks like it is out of date: "...to create a runnable JAR in Eclipse...". – Code-Apprentice Oct 27 '16 at 22:30
-
Ohh... sorry :( missed that. Other way is to use gradle then, run in command line from your project dir (with build.gradle) - "gradlew desktop:dist" – Mikhail Churbanov Oct 27 '16 at 22:47
-
@Rinold Thanks. I just found the `dist` task in the `desktop` project. Looks like it includes the `android/assets` directory when it builds the JAR file. – Code-Apprentice Oct 27 '16 at 22:51
-
https://github.com/libgdx/packr If you want to bundle the JRE to make it into an EXE. – Tenfour04 Oct 28 '16 at 12:57
-
@Tenfour04 Thanks for the link. That is a related, but different, question from what I am asking here. – Code-Apprentice Oct 28 '16 at 13:15
1 Answers
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