It took me a little while to get this working so hopefully I can save you some time with this little howto.
- Launch the Android SDK Manager and ensure you have installed the SDK platform for API 21 (Android 5.0) as well as the Google Play Services SDK way down the list in the extras section.
1.1) You will need to adjust your project’s Target Android API Level to 21. This helps avoid some little gotchas with getting this to work. You can keep the Min Android API Leve to whatever.
1.2) You’ll also need to get the C++ SDK from here:
https://developers.google.com/games/services/downloads/gpg-cpp-sdk.v2.1.zip
- Next go to where your Android SDK is installed and into the extras\google\google_play_services\libproject directory and copy the google-play-services_lib directory over to where your Android project file is.
This should be the same directory where you have your res, assets, jar, src and other directories. At the root of that directory should be your project file as well as a project.properties file which is used by ANT.
- Open a command window in that directory by holding shift and right clicking in that directory while in explorer. You should see an “open command window here…” in the drop down menu. You’ll also need to ensure that the android tools directory is in your path because you’ll need it next!
3.1) First we need to import the google play library into our project so in the command window, issue this line:
android update project --library .\google-play-services_lib -p .
This will update the project.properties file and you should see something like this in there once the operation completes:
android.library.reference.1=.\google-play-services_lib
- Next we need to update the google play services lib itself so move into the google-play-services_lib directory and then execute this:
android update lib-project -p . -t 6
So this preps it for being built and sets the API level to 21 (which is what level 6 is here).
- Unzip the GPG C++ SDK somewhere useful and then in your Visual Studio project settings under C++ → General, you’ll need to point the project include path to the GPG SDK include directory.
5.1) Add the path to the GPG library in Linker → General AND reference the actual library in Linker → Input. Remember to just reference it as gpg as opposed to libgpg.a.
- Finally, still in the projects settings, in Ant Build\Additional Dependencies you will have to specify the JAR directories to point to where your (Android SDK is installed)\extras\android\support\v4 and in the JAR Dependencies section add android-support-v4.jar
6.1) An easier thing to do is have a jar directory off the root of where your Android project file is and throw in all the JAR’s you need in there. For my project I have several so makes it easy to keep them in once place!
From there, you should be ready to roll!