Skip to content

Getting Started: Installing AndEngine

September 8, 2011

Note: these instructions are for the GLES1.0 version of AndEngine.  It provides greater compatibility and speed in most instances, though is no longer updated.  If you are interested in learning more about GLES2.0, check out andengine.org.

The first place to begin with AndEngine is: getting everything running!

Before taking these steps, make sure you have Eclipse running the latest version of the Android SDK.  If you’re new to Android and want a simple guide to get started, check Google’s documentation.  (If you still have any questions, feel free to email me or ask in the comments.)

Okay, so once you have Eclipse running with the Android SDK, the next step is to download the AndEngine source.  There are two ways to do this:

(1) To download the source as a JAR file here.

NOTE- This version of the JAR file is not the latest- it is not updated often.  If you want the latest version of AndEngine, check out option (2)…

In order to include the AndEngine code in a project, go to the project’s properties (right-click the project in the Package Explorer) and go to the Java Build Path tab.  From there, click “Add External JARs…” and select the JAR file you downloaded.  From there, you can import any android code.  This method is substantially simpler, with one simple downside: you can’t actually view or edit the code.  To do that,  you must…

(2) download the source as a part of an Android project here.

Before we get started: In order to download the set, you’ll need to install the Mercurial plugin.  Direct the Eclipse Update Manager to:

http://cbes.javaforge.com/update

and install Mercurial Eclipse (the installation should be similar to installing the Android SDK).  It warned me that I was using unsigned code: I haven’t had any trouble with it, and it’s a trusted app among developers, so if you find the same error, I believe it’s safe to continue.

Once Eclipse has restarted and Mercurial has been installed, you can import project code straight from google code into Eclipse.  To import the AndEngine source code, go to File -> Import, select the new option labeled Mercurial folder, and click “Clone Existing Mercurial Repository.”  From there, enter “https://andengine.googlecode.com/hg/” in the URL box, and it will make a clone of the code in your eclipse workspace.  After a short wait, it will ask you to select a working directory revision- select default, then press “finish” on the next screen to complete the copying process.  There you have it- the AndEngine code is now located on your computer!  It may show some errors- that’s normal, though hopefully within a few weeks it’ll be fixed.

If you’ve followed me up to this point, you should have a new project named AndEngine in your workspace directory.  Nicely done!  Now you need some examples of code so you can see how the engine works, as well as some plugins.  Go ahead and run Mercurial again, with the following Mercurial address: “https://andengineexamples.googlecode.com/hg/”

NOTE: As of right now, the AndEngineExamples have a few errors in the default configuration.  To fix this, download the AndEngine code by performing the same process using Mercurial with the following addresses:

http://code.google.com/p/andenginemultitouchextension/

http://code.google.com/p/andenginemultiplayerextension/

http://code.google.com/p/andengineaugmentedrealityextension/

http://code.google.com/p/andenginemodplayerextension/

http://code.google.com/p/andenginephysicsbox2dextension/

http://code.google.com/p/andenginesvgtextureregionextension/

http://code.google.com/p/andenginetexturepackerextension/

Sometimes, an error occurs where Eclipse won’t compile the project if a folder is missing; if this happens, simply find your workspace directory and create the folder manually, then close and re-open Eclipse.  It should resolve any remaining errors.  Also, in my project, one of the examples was reporting an error- making it an empty activity made everything compile and run simply!  

User Francis has pointed out one way to increase compatibility: 
Goto Project/Properties/Java Compiler and set the Compiler compliance level to at least 1.6.  This definitely helps.  Thanks!

Once you get the AndEngineExamples code working, you will find that there are two important parts of this project:

(1) The examples.  Almost anything you need to know about AndEngine is covered in the examples here: over the next few posts, I’ll go over a few of the most common ones, but if you want to explore them yourself, by all means, dive in!  At very least, compile the project and check out a few of the examples in action.

(2) The Source Code.  If you followed the instructions in the note above, you will now have the code as a separate project.  Congratulations- you should now be able to both view the AndEngine code and import it into any project in your workspace!

So, there you have it- you now have everything you need to begin coding with AndEngine!  Stay tuned, and we’ll take a look at how to make projects that will leave you the star of the Android Market!

Up Next: Getting Started: The Work Order of AndEngine

Advertisements
5 Comments
  1. André permalink

    Good morning,
    and thanks for the great tutorial! I’ve followed everything in Step 2 and have all the clones imported in Eclipse. However I still have a lot of errors which I can’t figure out how to resolve! I was wondering if you could give me any tips?

    here is a screenshot of the errors I get: http://www.andreborud.com/andengine.jpg

    //André

    • Hey André!
      Unfortunately, AndEngine is a bit of a mess right now- I have errors in all the projects as well. It’s an ugly solution, but for now, just ignore them and see if the AndEngineExamples project builds. If it does, then your project is working, and hopefully the errors will be resolved in a new build of AndEngine soon.

      If it’s not working for you, you may need to delete the project and start over or try the .jar files (posted here and on the forums). Hope you’re able to get everything working- if it’s still giving you trouble, let me know, and I’ll look into it!

  2. Carl permalink

    I had the same problems as you had Andre. It seemed the problem was that the Android library was not a part of the java build path, even though the project build target was properly selected to Android 2.2 (all this is found in the project properties). I don’t understand why this issue was, but it was resolved by manually selecting the project build target again. Hope this helps.

    The tutorial is great by the way! Many thanks!

  3. Francis permalink

    Try the following:
    Goto Project/Properties/Java Compiler and set the Compiler compliance level to at least 1.6.

    • Thanks for pointing this out to me! I’ve edited it into the guide, with props to you for pointing it out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: