diff --git a/samples-android/README.build b/samples-android/README.build index 63566aa..414326a 100644 --- a/samples-android/README.build +++ b/samples-android/README.build @@ -7,12 +7,12 @@ A set of the sample to demonstrate how to use Google Play Games Native Interface Pre-requisites -------------- -1. change the applicationId inside each individual samples build.gradle to your own package name -2. change app_id to your registered game ID, which was assigned to you by play game console +1. Change the applicationId inside each individual samples build.gradle to your own package name +1. Update the `app_id` and any configured constants in the sample's `src/main/res/values/id.xml` file to those registered in the [Play Games Services console](https://play.google.com/apps/publish) Build with Android Studio ------------------------- -This project need Android Studio 1.5+ with ndk support +This project requires Android Studio 1.5+ with ndk support 1. Launch Android Studio. 1. Open the sample project at cpp-android-basic-samples/samples-android 1. Disable "Instant Run" from Settings-> Build Execution, Deployment -> Instant Run @@ -26,26 +26,48 @@ This project need Android Studio 1.5+ with ndk support All projects could be built at one shot from Android Studio menu "Build" -> "Clean Project"/"Rebuild Project" you could also build with Gradle on Terminal/Command line -Build with Ant/ndk-build ------------------------- -The script needed for ant build are kept in the file structure. -The build script depends on the following environment variables to be set: -ANDROID_HOME to the path where the Android SDK is installed -NDK_ROOT to the path where the Android NDK is installed -NDK_MODULE_PATH to the location of the Play Games cpp libraries. -Change package name in AndroidManifest.xml to your own package -Change app_id (in string.xml/ids.xml) to your own one - -Note: NDK_MODULE_PATH should point one directory *above* where -you've installed gpg-cpp-sdk. This variable is used by ndk-build to locate -all installed modules, not just the Google Play Games library. - -- To build any individual project - - go to samples-android/your-selected-project/src/main, like samples-android/ButtonClicker/src/main - - execute build.sh -- To build all projects - - in samples-android directory, execute build.sh -The apk(s) will be placed into your-project-dir/src/main/bin +Build using Gradle on OS X or Linux +----------------------------------- +1. Install Android Studio +1. Set the path to the Android SDK + + export ANDROID_HOME=~/Library/Android/sdk + +1. Add the SDK to your path + + export PATH=$PATH;$ANDROID_HOME/tools;$ANDROID_HOME/platform-tools + +1. Set the path to the Android NDK + + export ANDROID_NDK_HOME=/android-ndk-r10e + +1. Execute the build script + + ./gradlew assemble + +Build on Windows using Gradle +----------------------------- +1. Install Android Studio +1. Set the path to the Android SDK + + set ANDROID_HOME=C:\Users\\AppData\Local\Android\sdk + +1. Add the SDK to your path + + set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools + +1. Set the path to the Android NDK + + set ANDROID_NDK_HOME=C:\Users\\Desktop\android-ndk-r10e + +1. (Optional) On some versions of Windows it is helpful to map the samples folder to a shortened path. + + subst G: C:\ + +1. Execute the build script + + G: + gradlew.bat assemble Support ------- diff --git a/samples-android/build.sh b/samples-android/build.sh deleted file mode 100755 index bec2469..0000000 --- a/samples-android/build.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -set -eua - -# List of targets to build. Interpreted as directories relative to -# this script's path. -declare targets=( \ - CollectAllTheStarsNative \ - Minimalist \ - TbmpSkeletonNative \ - Teapot \ - TrivialQuestNative \ - ButtonClicker \ -) - -declare -r script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# This little piece of code prepends the project name and a timestamp to every line in the -# output, which is kind of handy. -function add_timestamp { - while IFS= read -r line; do - echo "[${1}:$(date)] $line" - done -} - - -# Build each target in turn. -declare -i status=0 -declare -i pipestatus=0 -declare failed="Failures: " -for target in "${targets[@]}"; do - echo "Building ${target}..." >&2 - ${script_dir}/${target}/src/main/build.sh $@ 2>&1 \ - | add_timestamp ${target} | tee build.log - pipestatus=${PIPESTATUS[0]} - status=status+pipestatus - [ ${pipestatus} -ne 0 ] && failed=${failed}.${target} -done - -echo ${status} -echo ${failed} -[ ${status} -ne 0 ] && echo "Build failed" >&2 || echo "Build Succeeded" >&2 -exit ${status} - - diff --git a/samples-android/build_sample.sh b/samples-android/build_sample.sh deleted file mode 100644 index 4cee8ac..0000000 --- a/samples-android/build_sample.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash -set -eua - -declare result=0 -declare -r required_vars=( \ - ANDROID_HOME \ - NDK_ROOT \ - NDK_MODULE_PATH ) - -echo Checking Environment... >&2 - -# Check that all of the required environment variables are set, and -# point to valid paths. -# -for varname in ${required_vars[@]}; do - echo "Check ${varname}" -done - -[[ ${result} -ne 0 ]] && exit ${result} - -# Now check the subdirectories and files we'll actually be using -# to make sure they all exist. -# -declare -r lib_rel_path="/extras/google/google_play_services/libproject/\ -google-play-services_lib" - -# Paths to check -declare -r required_paths=( \ - "${ANDROID_HOME}/tools/android" \ - "${NDK_ROOT}/ndk-build" \ - "${ANDROID_HOME}/${lib_rel_path}/project.properties" - "${NDK_MODULE_PATH}/gpg-cpp-sdk/android/lib" - "./AndroidManifest.xml" - "./jni/Android.mk" ) - -# (Hopefully) helpful note to be displayed if a path check fails. Keep in -# sync with the "required_paths" array above. -declare -r remedies=( \ - "Be sure ANDROID_HOME points to the location of a valid Android SDK." \ - "Be sure NDK_ROOT points to the location of a valid Android NDK." \ - "Is the Play Games Services SDK package installed?" \ - "Have you downloaded and installed the Play Games Services SDK for C++?" \ - "Run this script from your project root." \ - "Is this an NDK project?" ) - -declare -i i=0 -for path in ${required_paths[@]}; do - if [[ ! -e "${path}" ]]; then - echo "ERROR: ${path} does not exist" >&2 - echo " ${remedies[i]}" >&2 - result=1 - fi - i=i+1 -done - -# Make sure ant is installed. -if [[ -z `which ant` ]]; then - echo "ERROR: Can't find ant on the PATH. Please (re)install ant." >&2 - result=1 -fi - -if [[ ${result} -ne 0 ]]; then - echo "Environment incorrect; aborting" >&2 - exit ${result} -fi - -echo Environment OK >&2 - -declare -x mode=${1:-debug} - -declare -r android_tool="${ANDROID_HOME}/tools/android" -declare -r ndk_build="${NDK_ROOT}/ndk-build" -declare -r lib_project="${ANDROID_HOME}/${lib_rel_path}" -declare -r android_support_v4="${ANDROID_HOME}/extras/android/support/v4/\ -android-support-v4.jar" - ->&2 echo Preparing projects... -declare -r private_lib=".gpg-lib" - -# Write out the local.properties file; replace the current one. -echo "# GENERATED by build_sample.sh -- do not modify." > local.properties -echo "sdk.dir=${ANDROID_HOME}" >> local.properties -echo "gpg.lib=${private_lib}" >> local.properties -${android_tool} update project --path . --target android-22 - -# -# Get a private copy of the library project -# -function cleanup() { - rm -rf ${private_lib} -} -# clean before copying to ensure no garbage is left behind... -cleanup -# ...and make sure *this* script leaves no garbage behind, either. -trap cleanup EXIT - -# Copy the lib project and run "android update lib-project" on it. -# This requires a target, which apparently needs to be android-10. -cp -r ${lib_project} ${private_lib} -mkdir -p libs -cp -f ${android_support_v4} ./libs - -${android_tool} update lib-project --path ${private_lib} --target android-22 - -# -# At last, build! -# -echo Building... >&2 -${ndk_build} "$@" -ant ${mode} - -if [ $# -gt 0 ] && [ "$1" = "clean" ] -then - rm -fr obj libs - rm -f build.xml proguard-project.txt -fi -echo Done >&2 diff --git a/samples-android/build_template.sh b/samples-android/build_template.sh deleted file mode 100755 index 9da25c3..0000000 --- a/samples-android/build_template.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -eua - -declare -r script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "${script_dir}" -source ../build_sample.sh -