Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d-x cookbook

You're reading from   Cocos2d-x cookbook Over 50 hands-on recipes to help you efficiently administer and maintain your games with Cocos2d-x

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781783284757
Length 254 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Akihiro Matsuura Akihiro Matsuura
Author Profile Icon Akihiro Matsuura
Akihiro Matsuura
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Cocos2d-x FREE CHAPTER 2. Creating Sprites 3. Working with Labels 4. Building Scenes and Layers 5. Creating GUIs 6. Playing Sounds 7. Working with Resource Files 8. Working with Hardware 9. Controlling Physics 10. Improving Games with Extra Features 11. Taking Advantages Index

Setting up our Android Environment

Getting ready

We begin by setting up our Android environment. If you wish to build only on iOS, you can skip this step. To follow this recipe, you will need some files.

The following list provides the prerequisites that need to be downloaded to set up Android:

  • Eclipse ADT (Android Developer Tools) with the Android SDK:

    https://dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip

    Eclipse ADT includes the Android SDK and Eclipse IDE. This is the Android development tool that is used to develop Android applications. Android Studio is an Android development IDE, but it is not supported to build NDK. The official site states that a version of Android Studio that supports NDK will be released soon. That's why we use Eclipse in this book.

  • Android NDK (Native Development Kit):

    https://dl.google.com/android/ndk/android-ndk-r10c-darwin-x86_64.bin

    The NDK is required to build an Android application. You have to use NDK r10c. This is because compiling and linking errors may occur when using NDK r9 or an earlier version.

  • Apache ANT:

    You can download Apache ANT from http://ant.apache.org/bindownload.cgi

    This is a java library that aids in building software. At the time of writing this book, version 1.9.4 was the latest stable version available.

How to do it...

  1. You begin by installing Eclipse ADT with the Android SDK, and then continue to unzip the zip file to any working directory you are aware of. I recommend that you unzip it to the Documents folder (~/adt-bundle-mac-x86_64-20140702). ADT includes Android SDK and Eclipse. The SDK and Eclipse folders are located under the ADT folder. We call the SDK folder path that is located under the ADT folder ANDROID_SDK_ROOT. You have to remember it because you will use it the next recipe. Now, you can launch Eclipse from ~/adt-bundle-mac-x86_64-20140702/eclipse/Eclipse.app.
  2. The next step is to update Android SDK:
    • Open Eclipse from the eclipse folder located in ADT.
    • Go to Window | Android SDK Manager.
    • After opening Android SDK Manager, check Tools and the latest Android SDK (API21), Android 2.3.3(API10), and any other SDK if necessary, as shown in the following screenshot:
      How to do it...
    • Click on Install packages....
    • Select each license and click on Accept, as shown in the following screenshot:
      How to do it...
    • After you accept all licenses, you will see that the Install button is enabled. Click on it.
    • You have to wait for a long time to update and install the SDKs.
  3. Installing NDK:

    Open the terminal window and change the directory to the path from which you downloaded the package. Change the permission on the downloaded package and execute the package. For example:

    $ chmod 700 android-ndk-r10c-darwin-x86_64.bin
    $ ./android-ndk-r10c-darwin-x86_64.bin
    

    Finally, you move the NDK folder to the Documents folder. We call the installation path for NDK NDK_ROOT. NDK_ROOT is the address of the folder that contains the files, it helps the Cocos2dx engine to locate the native files of Android. You have to remember NDK_ROOT because you will use it in the next recipe.

  4. Installing Apache ANT:

    Unzip the file to the Documents folder. That's all. We call ANT_ROOT the installation path for ANT. You have to remember ANT_ROOT, as we'll be using it in the next recipe.

  5. Installing Java:

    By entering the following command in the terminal, you can automatically install Java (if you haven't installed it earlier):

    $ java --version
    

    After installing it, you can check that it was successfully installed by entering the command again.

How it works...

Let's take a look at what we did throughout the recipe:

  • Installing Eclipse: You can use Eclipse as an editor for Cocos2d-x
  • Installing ADT: You can develop Android applications on Eclipse
  • Installing NDK: You can build a C++ source code for Java
  • Installing ANT: You can use command line tools for Cocos2d-x

Now you've finished setting up the Android development environment. At this point, you know how to install them and their path. In the next recipe, you will use them to build and execute Android applications. This will be very useful when you want to debug Android applications.

You have been reading a chapter from
Cocos2d-x cookbook
Published in: Nov 2015
Publisher:
ISBN-13: 9781783284757
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image