Deploying your application - garsue/libgdx GitHub Wiki
The mechanism to deploy your game differs between platforms. This article aims to articulate what is necessary to deploy to each platform that Libgdx officially supports.
The easiest way to deploy to Windows/Linux/Mac is to create a runnable JAR in Eclipse, which includes all of your code, the code of libgdx and any extensions, and your assets. To create a runnable JAR:
- Right click your desktop project, select "Export"
- In the next dialog, select "Java -> Runnable Jar", click "Next"
3. In the next dialog, specify the launch configuration you use to start the game on the desktop from within Eclipse, and select the output JAR file name
This will package all code and your assets into a single JAR file. To run the JAR file, a user can just double click it, provided she has Java installed.
A project worth mentioning is JarWrapper, a tool to bundle a JRE with your desktop jar file in a cross platform manner. this tool is in development.
Deploying to Android takes some extra steps. This tutorial is done using Eclipse and the Android ADT plugin.
- Right click your Android project and select "Export"
- Select "Android -> Export Android Application"
- Make sure the project you want to export is your project, select next
- Select or create your keystore. If you are new to Android development, a keystore is used to sign your applications and is required for putting your application on the market. More information is available at: http://developer.android.com/tools/publishing/app-signing.html
- Select your alias to sign with and enter the password. If you don't have an alias or want to create a new alias, select create new key and select next.
- Now select the destination of where you want your app being exported to. This will export an .apk file in the selected directory capable of being uploaded to Google Play (formerly Android Market) and alternative app stores.
- Select finish and your .apk will be built!
Notes
- The .apk file can be used to install on devices directly such as via an email attachment or download. This requires the devices to have the 'Allow Unknown Sources' option enabled in settings. Some carriers unfortunately disable this setting.
- LibGDX is only capable of officially exporting to devices running Android 2.2 or higher. If you are using LibGDX 0.9.9, you can export to Android 1.5+ Note that features supported by devices can vary, such as OpenGL ES 2 may not be supported on certain devices.
- OpenGL ES 2 requires Android 2.2 or higher and a graphics card supporting it.
- Features that are incompatible with the device such as trying to use immersive mode on a pre-kitkat device will simply not do anything on unsupported devices.
- If you want to upload to google play, here is a helpful link: http://developer.android.com/distribute/googleplay/publish/register.html
- LibGDX supports x86 Android devices starting with 0.9.9 and up. Make sure the x86 folder with libraries is in your project. Gdx-setup-ui should now generate your project with these.
TBD
Deploying to HTML/JS is straightforward for most cases.
- Right click your HTML project and select "Google -> GWT Compile"
- Keep the default settings and click compile
- A window will appear asking you to select the WAR directory. It is in your HTML project's folder.
- GWT will proceed to cross-compile your code into javascript. It will take awhile, but you can view the progress by pulling up the console in Eclipse.
Once the compile is complete everything you need to run your game on the web will be inside the WAR directory. Unless you are using RPC calls or other server side operations in your game, there are only a few things left to do.
- Copy the "index.html" file, your assets folder, and the folder ending in "mygdxgame.GWTDefinition" to a directory on your web server
- Navigate to the URL and you should see a loading screen for your game
Notes:
- If you are using server-side operations in your code, you will need to install Tomcat or similar software on your web server and place the full contents of your project's WAR directory in the "webapp" directory. More details here.