How to setup Libgdx for Android Studio
What is Android Studio?
Android studio is an IDE for Android developers. First announced earlier 2013, it has since grown to be a very effective tool. Last month, June 2014, Android Studio has went from alpha to beta. If you wish not to use an ‘in progress’ IDE, your other option is Eclipse. But hey, out with the old and in with the new. Source: http://en.wikipedia.org/wiki/Android_Studio
Unlike Eclipse, Android Studio is, in my own opinion:
· Faster
· Responsive
· Visually unified
· More productive
What is libGDX?
I like to call it a convenience. It is like XNA game studios for Android developers. It integrates easily into Android Studio, is cross-platform, and is super-fast. For a full detailed list, visit their feature page http://libgdx.badlogicgames.com/features.html
How to correctly setup libGDX
It took me three days to figure this out. I am letting you do it in one day.
Go to the libGDX download page and download the setup app. This file will generate an Android Studio Project with all the necessary libgdx libraries and cross-platform modules for you. http://libgdx.badlogicgames.com/download.html
1. This is only file you need to download.
2. Click on the download file and save it to your computer.
Save this file to your computer
3. Open the jar file. Then, fill in the dialog box as follows:
A. Leave Name: unchanged
B. Leave Package: unchanged.
C. Leave GameClass: unchanged
D. Go to your \AndroidStudioProjects Folder in the Library Explorer and create a new folder called \SetupGame. This is where our new project will be generated.
E. Change Destination to:
i. C:\Users\<USER_NAME>\AndroidStudioProjects\SetupGame
F. Change AndroidSDK to:
i. C:\Users\<USER_NAME>\AppData\Local\Android\android-studio\sdk
G. Leave all Sub Projects: checked
H. Uncheck the Box2d Extension unless you know you are going to use it.
I. Click Generate:
Do not worry, it is not as complicated as it looks
4. From the Android Studio welcome screen, click Import Project and select: C:\Users\<USER_NAME>\AndroidStudioProjects\SetupGame\build.gradld. This is going to open up the project for us.
Here you see the build.gradle file you need to import.
5. DO NOT PANIC. You will get this screen saying there is an error. This is easy to fix
As you see, there is an incompatible version begin used.
6. In your Library Explorer,
A. Navigate to C:\Users\<USER_NAME>\AndroidStudioProjects\SetupGame.
B. Right click on the .idea folder
C. Delete It.
Simple isn’t it. Just delete the .idea folder.
7. Back in Android Studio. Press (Ctrl+Alt+Y) to synchronize your project. A new .idea folder will be auto-generated with the correct contents. Honestly, I do not know why it does this. I just know that it works.
8. Double tap on any of the file breadcrumb tabs to open up the project file viewer screen.
Doesn’t this look so clean. Anyway, this is what you will see on the left-hand side of the screen.
9. Now open up your MySetupGame/build.gradle file and make one small change.
Change: classpath ‘com.android.tools.build:gradle:0.10+’ to …0.12+’
Yup, simply change that 0.10 to 0.12+
10. Sync your project again
If you do not get any errors, this is a success. you now have now setup libgdx for Android Studio.








No comments: