Skip to content

Commit 165f8be

Browse files
committed
Updating Native C++ samples to use recent plugin.
Also removed G+ dependency, cleaned up gpg_cpp dependency generation, and library processing. Change-Id: I3bfea1cd130b9eb52eebbdffbc56b613ccfb1077
1 parent 6729c0c commit 165f8be

File tree

17 files changed

+280
-160
lines changed

17 files changed

+280
-160
lines changed

README.md

Lines changed: 98 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
Google Play Games C++ SDK Samples for Android
2-
=============================================
3-
4-
Copyright (C) 2014 Google Inc.
5-
6-
<h2>Contents</h2>
7-
1+
Android Google Play Games Native Samples
2+
=======================================
83
These samples illustrate how to use Google Play Game Services with your Android game.
94

105
* **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.
@@ -21,16 +16,101 @@ These samples illustrate how to use Google Play Game Services with your Android
2116

2217
**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.
2318

24-
<h2>How to run a sample</h2>
25-
To use these samples, you need the Google Play Game Services C++ SDK, which you
26-
can [download from here](https://developers.google.com/games/services/downloads/).
19+
Pre-requisites
20+
--------------
21+
1. Change the applicationId inside each individual samples build.gradle to your own package name
22+
2. Modify res/values/ids.xml and place your IDs there, as given by the
23+
Developer Console (create the leaderboards and achievements necessary for
24+
the sample, if any). In the Developer console, select a resource type
25+
(Achievements, Events, Leaderboards) and click "Get Resources". Copy the
26+
contents from the console and replace the contents of res/values/ids.xml.
27+
28+
Build with Android Studio
29+
-------------------------
30+
This project requires Android Studio 1.5+.
31+
1. Android SDK version r10e or eariler.
32+
2. Launch Android Studio.
33+
3. Import the project by selecting File > New > Import Project and select
34+
samples-android/build.gradle.
35+
4. Edit the local.properties file (which is created by Android Studio) and
36+
set the ndk.dir property to the location of your r10e or eariler NDK.
37+
5. Change applicationId in the sample app build.gradle to your own package name
38+
that matches the configuration in the Play Game developer console.
39+
6. Replace res/values/ids.xml contents with your values from the developer console.
40+
7. Run the select project. Android Studio will compile, load and start your project on your device
41+
42+
All projects could be built at one shot from Android Studio menu "Build" -> "Clean Project"/"Rebuild Project"
43+
you could also build with Gradle on Terminal/Command line
44+
45+
Build using Gradle on OS X or Linux
46+
-----------------------------------
47+
1. Install Android Studio
48+
1. Set the path to the Android SDK
49+
50+
export ANDROID_HOME=~/Library/Android/sdk
51+
52+
1. Add the SDK to your path
53+
54+
export PATH=$PATH;$ANDROID_HOME/tools;$ANDROID_HOME/platform-tools
55+
56+
1. Set the path to the Android NDK
57+
58+
export ANDROID_NDK_HOME=<PATH_TO_NDK>/android-ndk-r10e
59+
60+
1. Execute the build script
61+
62+
./gradlew assemble
63+
64+
Build on Windows using Gradle
65+
-----------------------------
66+
1. Install Android Studio
67+
1. Set the path to the Android SDK
68+
69+
set ANDROID_HOME=C:\Users\<yourusername>\AppData\Local\Android\sdk
70+
71+
1. Add the SDK to your path
72+
73+
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
74+
75+
1. Set the path to the Android NDK
76+
77+
set ANDROID_NDK_HOME=C:\Users\<yourusername>\Desktop\android-ndk-r10e
78+
79+
1. (Optional) On some versions of Windows it is helpful to map the samples folder to a shortened path.
80+
81+
subst G: C:\<full-path-to-sample-folder>
82+
83+
1. Execute the build script
84+
85+
G:
86+
gradlew.bat assemble
87+
88+
Support
89+
-------
90+
If you've found an error in these samples, please [file an issue](https://github.com/playgameservices/cpp-android-basic-samples/issues/new).
91+
92+
Patches are encouraged, and may be submitted by [forking this project](https://github.com/playgameservices/cpp-android-basic-samples/fork) and
93+
submitting a pull request through GitHub. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
94+
95+
- [Stack Overflow](http://stackoverflow.com/questions/tagged/google-play-games)
96+
- [Android Tools Feedbacks](http://tools.android.com/feedback)
97+
98+
99+
License
100+
-------
101+
Copyright 2015 Google, Inc.
102+
103+
Licensed to the Apache Software Foundation (ASF) under one or more contributor
104+
license agreements. See the NOTICE file distributed with this work for
105+
additional information regarding copyright ownership. The ASF licenses this
106+
file to you under the Apache License, Version 2.0 (the "License"); you may not
107+
use this file except in compliance with the License. You may obtain a copy of
108+
the License at
27109

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

34-
<h2>Acknowledgment</h2>
35-
Some of these samples use the following open-source project:
36-
JASONCPP: https://github.com/open-source-parsers/jsoncpp
112+
Unless required by applicable law or agreed to in writing, software
113+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
114+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
115+
License for the specific language governing permissions and limitations under
116+
the License.

samples-android/ButtonClicker/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ evaluationDependsOn(':Common/gpg-sdk')
66
// As the plugin has created the build tasks, add the gpg-sdk task to
77
// the task dependencies so it gets done before compiling
88
tasks.whenTaskAdded { task ->
9-
if (task.name.equals("preBuild")) {
10-
project(':Common/gpg-sdk').defaultTasks.each { t ->
11-
task.dependsOn project(':Common/gpg-sdk').tasks[t]
9+
project(':Common/gpg-sdk').defaultTasks.each {
10+
t ->task.dependsOn project(':Common/gpg-sdk').tasks[t]
11+
1212
}
13-
}
1413
}
1514

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

3837
defaultConfig.with {
39-
applicationId="com.google.example.games.ButtonClicker"
38+
//
39+
// REPLACE THE APPLICATION ID with your bundle ID
40+
//
41+
applicationId="com.google.example.games.ReplaceMe"
4042
minSdkVersion.apiLevel = 11
4143
targetSdkVersion.apiLevel = 23
4244
}
@@ -85,6 +87,5 @@ model {
8587
dependencies {
8688
compile 'com.google.android.gms:play-services-games:8.4.0'
8789
compile 'com.google.android.gms:play-services-nearby:8.4.0'
88-
compile 'com.google.android.gms:play-services-plus:8.4.0'
8990
compile 'com.android.support:support-v4:23.1.1'
9091
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}

samples-android/CollectAllTheStarsNative/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ evaluationDependsOn(':Common/gpg-sdk')
66
// As the plugin has created the build tasks, add the gpg-sdk task to
77
// the task dependencies so it gets done before compiling
88
tasks.whenTaskAdded { task ->
9-
if (task.name.equals("preBuild")) {
10-
project(':Common/gpg-sdk').defaultTasks.each { t ->
11-
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12-
}
9+
project(':Common/gpg-sdk').defaultTasks.each {
10+
t ->task.dependsOn project(':Common/gpg-sdk').tasks[t]
11+
1312
}
1413
}
1514

@@ -36,7 +35,10 @@ model {
3635
buildToolsVersion = "23.0.2"
3736

3837
defaultConfig.with {
39-
applicationId = "com.google.example.games.cats"
38+
//
39+
// REPLACE THE APPLICATION ID with your bundle ID
40+
//
41+
applicationId="com.google.example.games.ReplaceMe"
4042
minSdkVersion.apiLevel = 11
4143
targetSdkVersion.apiLevel = 23
4244
versionCode = 1.0
@@ -87,7 +89,6 @@ model {
8789
}
8890
dependencies {
8991
compile 'com.google.android.gms:play-services-games:8.4.0'
90-
compile 'com.google.android.gms:play-services-nearby:8.4.0'
9192
compile 'com.google.android.gms:play-services-plus:8.4.0'
9293
compile 'com.android.support:support-v4:23.1.1'
9394
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}

samples-android/Common/gpg-sdk/build.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ fetch_gpg_cpp_sdk.description = "Download the gpg sdk from the specified locatio
2323

2424
task unzip_gpg_sdk() {
2525
doFirst {
26-
copy {
27-
from(zipTree('gpg_cpp_sdk.zip')) {
28-
exclude 'gpg_cpp_sdk/ios'
29-
}
26+
if (!file('gpg-cpp-sdk').exists()) {
27+
copy {
28+
from(zipTree('gpg_cpp_sdk.zip')) {
29+
exclude 'gpg-cpp-sdk/ios/**/*'
30+
}
3031

31-
into { project.projectDir }
32+
into { project.projectDir }
33+
}
3234
}
3335
}
34-
outputs.dir('gpg_cpp_sdk/android')
35-
outputs.upToDateWhen {file('gpg_cpp_sdk/android').exists()}
36+
outputs.dir('gpg-cpp-sdk/android')
37+
outputs.upToDateWhen {file('gpg-cpp-sdk/android').exists()}
3638
description = "Unzips the GPG SDK into the correct dir for NDK"
3739
dependsOn fetch_gpg_cpp_sdk
3840
}

samples-android/Minimalist/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ evaluationDependsOn(':Common/gpg-sdk')
66
// As the plugin has created the build tasks, add the gpg-sdk task to
77
// the task dependencies so it gets done before compiling
88
tasks.whenTaskAdded { task ->
9-
if (task.name.equals("preBuild")) {
10-
project(':Common/gpg-sdk').defaultTasks.each { t ->
11-
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12-
}
9+
project(':Common/gpg-sdk').defaultTasks.each {
10+
t ->task.dependsOn project(':Common/gpg-sdk').tasks[t]
11+
1312
}
1413
}
1514

@@ -37,7 +36,10 @@ model {
3736
buildToolsVersion = "23.0.2"
3837

3938
defaultConfig.with {
40-
applicationId = "com.google.example.games.Minimalist"
39+
//
40+
// REPLACE THE APPLICATION ID with your bundle ID
41+
//
42+
applicationId="com.google.example.games.ReplaceMe"
4143
minSdkVersion.apiLevel = 11
4244
targetSdkVersion.apiLevel = 23
4345

@@ -85,6 +87,5 @@ model {
8587
dependencies {
8688
compile 'com.google.android.gms:play-services-games:8.4.0'
8789
compile 'com.google.android.gms:play-services-nearby:8.4.0'
88-
compile 'com.google.android.gms:play-services-plus:8.4.0'
8990
compile 'com.android.support:support-v4:23.1.1'
9091
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}

0 commit comments

Comments
 (0)