Once Eclipse has
been setup correctly with the correct ADT, we can begin to import the AndEngine
libraries and Box2D extensions into our project. A developer has to go to either https://github.com/nicolasgramlich
or to https://github.com/RealMayo
and select the repositories tab. I
personally chose to work with RealMayo’s repositories as RealMayo provides the
same framework as Nicolas, but has an updated version that assists with Meshes
and textured meshes. Inside of the
repository folder, one should select the AndEngine project and visit that page. From the AndEngine code page, one may select
the branch that he or she wishes to work with and then select to download as a
zip file. In my project, I have
initially chosen to work with the GLES branch, but later on migrated to GLES-AC
branch, which used an anchoring system.
The user can then click the back button within their browser and then
select the Physics Box2d AndEngine extension and also repeat the steps of
selecting the branch and downloading the library, as a zip file, from the
respective GitHub page. Once the download
has completed, the user should extract both zip files, AndEngine zip and the
Physics Box2d AndEngine Extension zip, into the Android root directory, under a
newly created folder called ext or extensions.
Once this is
completed, the user should begin to import the project’s libraries into eclipse. This can be done within eclipse by selecting
File -> Import -> General -> Existing Projects into WorkSpace ->
Next and then selecting the root directory where the imported libraries are
located. If the user created an extension
directory inside the Android root directory, the user would just select the
extension directory. Once the directory
has been select, eclipse will show a new window as shown below.
Figure 1- Importing AndEngine
Libraries into Eclipse
The user will
then have to select the libraries that he wishes to import and then proceed to
press the next button. Eclipse will go
about importing the projects. Another method a
user can chose to use is using the Git server to import he projects. The user would start within eclipse, and then
select File -> Import -> Git -> Projects From Git -> Next. From there, a user can select Uri from the
menu options and then proceed to enter the URI in the following menu as shown
below. After selecting next, the user
would then select the branch which is shown in the second image to the right.
The user can
then click next and Eclipse will automate the process of downloading the library
from the repository and importing the projects into eclipse for easy
access. Once we have successfully
imported the libraries, we need to do some configurations to get them to build
successfully. A common user complaint is
that the Java compiler error gives a warning and will not allow the projects to
be built successfully. This can be
overcome by right clicking on the project library in the package explorer
window in Eclipse, and selecting properties.
From here a user can click the Java Compiler Menu option from the left,
and can set his Java Compiler Compliance level to 1.6, in case the compile
compliance level was set to 1.7.
Eclipse should automatically rebuild the project and clear any
compliance error issues. From here, we
only need to complete one more configuration step to begin working with
AndEngine inside of Eclipse. If we right
click on our AndEnginePhsyicsBox2DExtension project and select properties, we
should click the Android menu option.
From here, if we scroll to the bottom of the screen, there should be a
section for Libraries. There should be a
red X mark next to the AndEngine library, which is caused by incorrect
paths. We can correct this by highlighting
the AndEngine project within the library menu and then selecting remove. A user may then proceed to select add from
the right portion of the menu and then select AndEngine as shown below. When the user presses ok, Eclipse should
rebuild the project automatically and the projects should now show no
compilation or build errors. We are now
ready to begin coding in our AndEngine Eclipse environment.
Figure 3 - Fixing Path issues related
to AndEngine Physics Box2D import
This also detailed in a video posted by Real Mayo at the youtube video below
This also detailed in a video posted by Real Mayo at the youtube video below