Skip to content

Commit

Permalink
Updating Native C++ samples to use recent plugin.
Browse files Browse the repository at this point in the history
Also removed G+ dependency, cleaned up gpg_cpp dependency generation,
and library processing.

Change-Id: I3bfea1cd130b9eb52eebbdffbc56b613ccfb1077
  • Loading branch information
claywilkinson committed Aug 8, 2016
1 parent 6729c0c commit 165f8be
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 160 deletions.
116 changes: 98 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Google Play Games C++ SDK Samples for Android
=============================================

Copyright (C) 2014 Google Inc.

<h2>Contents</h2>

Android Google Play Games Native Samples
=======================================
These samples illustrate how to use Google Play Game Services with your Android game.

* **CollectAllTheStarsNative**: Demonstrates how to use the Saved Games feature to save game data. The sample signs the user in, synchronizes their data from a named game save, and then updates the UI to reflect the saved game state.
Expand All @@ -21,16 +16,101 @@ These samples illustrate how to use Google Play Game Services with your Android

**Note:** In samples with corresponding counterparts for iOS and Web (particularly, CollectAllTheStars and TypeANumber), the player can play a game seamlessly across phones of different platforms. For example, you can play some levels of CollectAllTheStars on your Android device, and then pick up your iOS device and continue where you left off! TypeANumber shows your achievements and leaderboards on all platforms; when you make progress on one platform, that progress is reflected on the other devices, as well.

<h2>How to run a sample</h2>
To use these samples, you need the Google Play Game Services C++ SDK, which you
can [download from here](https://developers.google.com/games/services/downloads/).
Pre-requisites
--------------
1. Change the applicationId inside each individual samples build.gradle to your own package name
2. Modify res/values/ids.xml and place your IDs there, as given by the
Developer Console (create the leaderboards and achievements necessary for
the sample, if any). In the Developer console, select a resource type
(Achievements, Events, Leaderboards) and click "Get Resources". Copy the
contents from the console and replace the contents of res/values/ids.xml.

Build with Android Studio
-------------------------
This project requires Android Studio 1.5+.
1. Android SDK version r10e or eariler.
2. Launch Android Studio.
3. Import the project by selecting File > New > Import Project and select
samples-android/build.gradle.
4. Edit the local.properties file (which is created by Android Studio) and
set the ndk.dir property to the location of your r10e or eariler NDK.
5. Change applicationId in the sample app build.gradle to your own package name
that matches the configuration in the Play Game developer console.
6. Replace res/values/ids.xml contents with your values from the developer console.
7. Run the select project. Android Studio will compile, load and start your project on your device

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 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=<PATH_TO_NDK>/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\<yourusername>\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\<yourusername>\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:\<full-path-to-sample-folder>

1. Execute the build script

G:
gradlew.bat assemble

Support
-------
If you've found an error in these samples, please [file an issue](https://github.com/playgameservices/cpp-android-basic-samples/issues/new).

Patches are encouraged, and may be submitted by [forking this project](https://github.com/playgameservices/cpp-android-basic-samples/fork) and
submitting a pull request through GitHub. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more details.

- [Stack Overflow](http://stackoverflow.com/questions/tagged/google-play-games)
- [Android Tools Feedbacks](http://tools.android.com/feedback)


License
-------
Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

After downloading the archive, unzip it to the `./gpg-cpp-sdk` directory. Then, follow [these directions](https://developers.google.com/games/services/cpp/GettingStartedNativeClient).
<h2> Other resources </h2>
* [Google Android Vulkan Tutorials](https://github.com/ggfan/android-vulkan-tutorials)
* [Android Vulkan API Basic Samples](https://github.com/googlesamples/vulkan-basic-samples)
* [Google Android NDK Samples](https://github.com/googlesamples/android-ndk)
http://www.apache.org/licenses/LICENSE-2.0

<h2>Acknowledgment</h2>
Some of these samples use the following open-source project:
JASONCPP: https://github.com/open-source-parsers/jsoncpp
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
13 changes: 7 additions & 6 deletions samples-android/ButtonClicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ evaluationDependsOn(':Common/gpg-sdk')
// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
project(':Common/gpg-sdk').defaultTasks.each {
t ->task.dependsOn project(':Common/gpg-sdk').tasks[t]

}
}
}

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
Expand All @@ -36,7 +35,10 @@ model {
buildToolsVersion="23.0.2"

defaultConfig.with {
applicationId="com.google.example.games.ButtonClicker"
//
// REPLACE THE APPLICATION ID with your bundle ID
//
applicationId="com.google.example.games.ReplaceMe"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23
}
Expand Down Expand Up @@ -85,6 +87,5 @@ model {
dependencies {
compile 'com.google.android.gms:play-services-games:8.4.0'
compile 'com.google.android.gms:play-services-nearby:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
}
20 changes: 20 additions & 0 deletions samples-android/ButtonClicker/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
13 changes: 7 additions & 6 deletions samples-android/CollectAllTheStarsNative/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ evaluationDependsOn(':Common/gpg-sdk')
// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
project(':Common/gpg-sdk').defaultTasks.each {
t ->task.dependsOn project(':Common/gpg-sdk').tasks[t]

}
}

Expand All @@ -36,7 +35,10 @@ model {
buildToolsVersion = "23.0.2"

defaultConfig.with {
applicationId = "com.google.example.games.cats"
//
// REPLACE THE APPLICATION ID with your bundle ID
//
applicationId="com.google.example.games.ReplaceMe"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23
versionCode = 1.0
Expand Down Expand Up @@ -87,7 +89,6 @@ model {
}
dependencies {
compile 'com.google.android.gms:play-services-games:8.4.0'
compile 'com.google.android.gms:play-services-nearby:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
}
20 changes: 20 additions & 0 deletions samples-android/CollectAllTheStarsNative/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
16 changes: 9 additions & 7 deletions samples-android/Common/gpg-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ fetch_gpg_cpp_sdk.description = "Download the gpg sdk from the specified locatio

task unzip_gpg_sdk() {
doFirst {
copy {
from(zipTree('gpg_cpp_sdk.zip')) {
exclude 'gpg_cpp_sdk/ios'
}
if (!file('gpg-cpp-sdk').exists()) {
copy {
from(zipTree('gpg_cpp_sdk.zip')) {
exclude 'gpg-cpp-sdk/ios/**/*'
}

into { project.projectDir }
into { project.projectDir }
}
}
}
outputs.dir('gpg_cpp_sdk/android')
outputs.upToDateWhen {file('gpg_cpp_sdk/android').exists()}
outputs.dir('gpg-cpp-sdk/android')
outputs.upToDateWhen {file('gpg-cpp-sdk/android').exists()}
description = "Unzips the GPG SDK into the correct dir for NDK"
dependsOn fetch_gpg_cpp_sdk
}
Expand Down
13 changes: 7 additions & 6 deletions samples-android/Minimalist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ evaluationDependsOn(':Common/gpg-sdk')
// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
project(':Common/gpg-sdk').defaultTasks.each {
t ->task.dependsOn project(':Common/gpg-sdk').tasks[t]

}
}

Expand Down Expand Up @@ -37,7 +36,10 @@ model {
buildToolsVersion = "23.0.2"

defaultConfig.with {
applicationId = "com.google.example.games.Minimalist"
//
// REPLACE THE APPLICATION ID with your bundle ID
//
applicationId="com.google.example.games.ReplaceMe"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23

Expand Down Expand Up @@ -85,6 +87,5 @@ model {
dependencies {
compile 'com.google.android.gms:play-services-games:8.4.0'
compile 'com.google.android.gms:play-services-nearby:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
}
20 changes: 20 additions & 0 deletions samples-android/Minimalist/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Loading

0 comments on commit 165f8be

Please sign in to comment.