Integrate GameCircle With an Ant Project

I was integrating an Android game with GameCircle by following Amazon’s documentation, and I eventually arrived to “Initializing GameCircle in Your Game”. The documentation instructs to import GameCircle SDK into Eclipse’s workspace and add it as a dependency. Since I wasn’t using Eclipse, I had to setup the dependency using Ant.

GameCircle SDK looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
GameCircleSDK/
├── AndroidManifest.xml
├── bin
│   └── placeholder.txt
├── gen
│   └── placeholder.txt
├── jni
│   ├── includes
│   │   └── ...
│   └── libAmazonGamesJni.so
├── libs
│   ├── AmazonInsights-android-sdk-2.1.16.jar
│   ├── gamecirclesdk.jar
│   └── login-with-amazon-sdk.jar
├── project.properties
└── res
    ├── drawable
    │   └── rounded_corners.xml
    ├── layout
    │   └── modal_overlay_container.xml
    ├── raw
    │   └── amazon_gc_prototype.zip
    └── values
        └── amazon_gc_styles.xml

The obvious and easy solution is to merge all these files into my project. It would work, but I would prefer to keep the SDK external to my source tree to make updates easier. It can be done in two easy steps.

Step 1 – Add GameCircle as a reference

In my project, I first added the SDK path to local.properties:

1
sdk.gamecircle=../../../tools/Amazon-SDK/Android/GameCircle/GameCircleSDK/

This file isn’t checked into source control, so it’s a good place to put a machine-specific path. The path must be relative, because Ant treats / as the base of the project and not the root of the file system. Then I referenced the SDK in project.properties.

1
android.library.reference.1=${sdk.gamecircle}

When I tried to compile, I got an error:

1
2
BUILD FAILED
/.../tools/ant/build.xml:601: Invalid file: /.../GameCircleSDK/build.xml

Step 2 – Prepare GameCircle for Ant

In GameCircle SDK, generate build.xml:

1
android update lib-project --path /path/to/gamecirclesdk

Still one error remaining:

1
2
BUILD FAILED
/.../ant/build.xml:659: /.../GameCircleSDK/src does not exist.

I just created an empty directory named src, and the project compiled successfully.

Done! I could continue following the documentation.