web analytics
Paste your Google Webmaster Tools verification code here

Android GDX Game Creation (Part I) – setting up up Android Studio for Creating Games

badlogic

Introduction

One way to make extra income if you are a developer is to start creating games for the Android OS.  In the past, this could prove difficult on the Android,  because you either had to buy an expensive tool such as Unity or you needed to write in OpenGL which is downright painful.  BadLogic’s gdx library makes it much easier to get started writing games.  It provides a simple architecture along with some helpful classes for quickly getting together a simple 2d game.  The gdx library is open source and is also written in such a way as to allow you to use the same source code for multiple platforms including the desktop, ios, and even html. The open source community is constantly updating the library and building in richer and versatile features.

Setting up the Environment for Android Studio

This will probably prove the most challenging for getting started, but once you’ve got the basic template for gdx setup, you’ll be ready to go.  The easiest way to create a gdx setup, is to run the gdx-setup.jar  file which creates a gradle ready project that can be imported into Android Studio.  Simply download the gdx-setup from the link above ,  launch the command prompt from the pc (type cmd)  and run the following line:

java -jar  <directory you downloaded the gdx-setup>/gdx-setup.jar

This will Launch a java GUI project generator, that will allow you to generate your project.

GDXSetup

 

You’ll need to browse for where your android sdk is.  You can figure out the path by going into Android studio, and going to the menuTools -> Android -> SDK Manager.  Once you launch the manager, it will display the path for all the SDKs.  While you are in the SDK Manager, you may want to make sure you have upgraded to the 19.1 tools, because its required for the gdx-setup.jar to build properly.

You can uncheck iOS,  Html, and Desktop if you are only planning on building an Android project.  Leave Box2D checked, because this may be useful for you in writing your Android game.

When you are ready, click generate and wait for the project to be created.

Bringing the Project into Android Studio

Once the gdx-setup is finished running, you can import the build.gradle file into Android Studio.  Go to File -> Import in the Android Studio menu, and browse for the build.gradle under your project directory that you set in destination when you ran the gdx-setup generator.

import

 

Click Okay, and Android Studio will precede to bring in the project using gradle and download everything it needs.  Once its finished, your android directory structure will looking something like the figure below:

projectstructure

 

Building and Running

You can build the application from the Build -> Make Project menu item inside of Android Studio.  It may take a while, but once its finished you are ready to run on your Android.  Hook a USB up to your Android device.  You’ll have needed to setup up your Android device settings to allow for Debugging through a USB.  You’ll also need to have installed all the required drivers through the SDK Manager.  If all is well, when you run the android project, you’ll see the screen turn red, and a sample image called badlogic.jpg show up in the bottom left hand corner of your device.

Conclusion

GDX Lib is a free versatile java library for creating device independent games.  In order to use it in the Android Studio environment, you should use gdx-setup to generate what you need for your game project framework.  In the next article we’ll get into how to move actors around the screen using the gdx library and begin our journey into our first game.

 


Mike is a software engineer with a love for tinkering with smart phone devices. He spends a lot of time moving pictures to his SD card, because the Android keeps running out of memory. In his spare time, he travels to different parts of the world and takes one of his Android devices with him.

Share

Share This Post

Related Articles

12 Responses to “Android GDX Game Creation (Part I) – setting up up Android Studio for Creating Games”

  1. nicely wright-up tutorial…

  2. guest says:

    I like it when individuals come together and share views.
    Great blog, keep it up!

  3. mike g says:

    I recently upgraded to android 0.8.2 and noticed in order to get the gdx-lib project to work again, you need to change the classpath for gradle at the project level. Open up the build.gradle file at the project level and change the classpath to the latest gradle plugin and your gdx-lib project should work again

    dependencies {
    classpath ‘de.richsource.gradle.plugins:gwt-gradle-plugin:0.4’
    classpath ‘com.android.tools.build:gradle:0.12+’
    classpath ‘com.github.jtakakura:gradle-robovm-plugin:0.0.9’
    }

  4. iceybobby says:

    Thanks for the tutorial. I wasn’t sure if it would work with all the other non-android project and the two build.gradle’s.

  5. Custer says:

    I was having lots of problems using it, thanks for the tutorial!

  6. Julien says:

    Great.
    It would be great if you could update the LibGDX wiki https://github.com/libgdx/libgdx/wiki with your instructions.
    This will help a lot of people get started and promote LibGDX overall.
    Nice work

  7. hossein says:

    hi , in new version of android studio for import you must select a
    import project (Eclips ADT ,Gradle,etc.)
    and then select folder generated with gdx-setup

  8. John says:

    Thanks so much for this guide, it help me generate libgdx.
    I was stuck for a day downloading software I thought I needed for the development Environment.
    It turns out my problem was to manually type this directory to locate Android Directory path:
    C:\Users\John\AppData\Local\Android\sdk

    That too way too long to end with that.

  9. Ahmed says:

    i have a problem that i can’t install the gdx it gave me windows installer error,and i tried to install with the windows command but it say access is denied.

  10. I followed till the step where we clicked “generate”. It started downloading some files like
    services.gradle.org/distributions/gradle-2.4-all.zip, and some other. It took a lot of time. So, will it download these files every time i create a project?

Leave a Reply

*

© 2016 ToDroid. All rights reserved.
Disclaimer: The content on this site is copyrighted. Do not copy the content. The content on this site must not be reproduced anywhere else.