How to Setup Andengine with Android Studio

Okay you decided to start with Andengine and i think you want to use Android Studio instead of Eclipse.
Instead of starting a fight “eclipse VS android studio” it is much easier (currently) to setup eclipse for andengine.

However for our first project we want to use android studio from the beginning.

1. Prerequisite

You need the following before you can start:

  • Android Studio (Download)
  • Android SDK configured and Download (you can do this directly in Android Studio)

I will not go deeper in how you setup an Android Studio IDE – i think you can google that if you need help.


2. Create a new Project

Fire Up Android Studio and click “File” -> “New Project” .
Now fill out Application Name and Company Domain and choose a directory where you want to place this Project.

On the next Screen you can choose a Minimum SDK.
Choose API Level 9 (Android 2.3) – this is the minimum where AndEngine should work.

On the next Screen choose “Blank Activity” (we just need it for displaying the Surface View).

At least give the Activity a name for example “MainActivity”.

Click finished and you are done with setup the Android Project.


3. Add Andengine to our Project

– Click on “File” -> “Project Structure”
– On the new Window click the green “+” sign and you will see a new Wizard (see the image).


Just select “Import existing Project” and choose the Path for the Andengine Eclipse Project.
This is the way to import AndEngine into the Project.

You should now “Open Module Settings” and check the “Dependencies” Tab.
AndEngine GLES2 should now be added as Module Dependeny.

If it is a Library Dependency – remove the entry and add it as Module Dependency.


Now Gradle is doing his work as usual.

After that we are able to add our Surface View in the Activity.

So open your layout file “activity_main.xml” (or whatever you name your layout/activity) and change it as the following:

As you may want a fullscreen view without the action bar, switch to res/styles.xml and change your theme to somewith with NoActionBar for example “Theme.AppCompat.Light.NoActionBar” .


4. Add AndEnginePhysicsBox2DExtension

Repeat the Steps from 3. but just select the Path for the AndEnginePhysicsBox2DExtension.

Now the important part: You need to add the “” from the extensions “lib” folder to your projects “libs” folder.

You should do this for every platform (armeabi, armabi-v7, mips, x86…).

Otherwise you get the Error “java.lang.UnsatisfiedLinkError: Couldn’t load andenginephysicsbox2dextension from loader …”.


5. Add Permissions to the Manifest

The following Permissions should be added to the Manifest:

Wake Lock is important the Screen doesnt disappear after some seconds. Vibration is nice for some game related features.

However : Internet and Network State are not directly Game related. They are needed if you want to place some Advertisements in your Game.


6. Setup the Main Activity

Now we have all to start happy coding 🙂

First switch to your Activity and change the “extends” Class to “LayoutGameActivity”.

Android Studio now wants to implement the missing Methods – just press “ALT + Enter”.

Next we need a camera. So define some Variabler for camera and the scene.

Change your onCreateEngineOptions as below:

We do some Setup for our Engine like enabling Music & Sound and define the Orientation to Protrait.


Now we must implement some other Methods from the Interface :

Short Explanation: i just pass the default methods back so we can finish our setup.
In “getLayoutID” is just the Resource ID for your Activity Layout.
The “gerRenderSurfaceViewID” is the Resource ID for the Surface View that we definied in Step 3.


If everythin is correctly just build and run and it should come up with your game.


Leave a Reply to Monkey King Thieves hack tool Cancel reply

Your email address will not be published. Required fields are marked *