Welcome to Google's C++ Class. This class includes written materials, lecture videos, examples, and exercises to practice C++ coding.
To get started, follow the links to the left.
Feb 22, 2020 How to Add a Device to Google Play Store. When you add a device to Google Play, you can access your previous app, movie, music, book and other purchases on the new device. You can quickly add Android devices by signing in with the same.
Tip: Check out the C++ Google Code University Forum to ask and answer questions.
Table of Contents
Getting Started
- Getting Started
- Learn by Example #1
- What it's like to be a software engineer at Google
- Exercises and Projects
- Application: Visualizing Music with Animation
Next Steps
- Introduction to Programming and C++
- Learn by Example #2
- The wonders of Science: Computer Science (a video)
- Exercises
- Database Project
- Welcome to the Real World!
- Application: A Study in Anatomy
C++ In Depth
- C++ Language Tutorial
- Object-Oriented Design
- Learn by Example #3
- Programming Humor (really!)
- Unit Testing
- How Google Works
- Application: Go Anywhere!
Quiz
Additional Resources
Before you begin
This developer guide will show you how to compile and run a C++ game on Android that uses the Google PlayGame services API. Before you begin, download and configure the following requirements:
- Android NDK, Revision 14 or higher.
- Android SDK v10 or higher and latest version of the Eclipse ADT.
- Device must be running Android 4.0 (API level 14) or higher.
This developer guide uses the Android Native Development Kit (NDK). If you are unfamiliar with the NDK,refer to the NDK documentation and samplesbefore continuing.
Step 1: Set up your environment
- Download the Android SDK and the Android NDK and extract them to your machine. In yourenvironment, set
SDK_ROOT
to the location of your Android SDK folder andNDK_ROOT
to thelocation of your Android NDK folder. - Download the C++ sample games. Thisdeveloper guide refers to the location of the samples on your machine as
SAMPLES_DIR
. - Download the Google Play Games services C++ SDK. Extract theSDK onto your development machine. In your environment, set the variable
NDK_MODULE_PATH
topoint to the directory above thegpg-cpp-sdk
directory. You should have the followingdirectory structure: - Open Eclipse. If you have not already done so, tell Eclipse where you installed the NDK byclicking Preferences > Android > NDK.
- Import the Google Play services library project into your Eclipse workspace.
- In Eclipse, click File > Import > Android > Existing Android Code into Workspace.
- Select
SDK_ROOT/extras/google/google_play_services/libproject/google-play-services_lib
whereSDK_ROOT
is the location of your Android SDK. - Click Finish.
- Import the minimalist sample project into your Eclipse workspace.
- In Eclipse, click File > Import > Android > Existing Android Code into Workspace.
- Select
SAMPLES_DIR/samples-android/minimalist
. - Click Finish.
- Right click the MinimalistActivity project and click Properties. Under Android, scrolldown to the Library section and make sure the google-play-services_lib project is correctlyreferenced. If not, remove the reference and add it again from your workspace.
Eclipse will automatically compile the Java and Android sources of your project; however, thenative code in the
jni
folder needs to be compiled separately. To do this manually, navigate tothe jni
folder and run ndk-build
. Remember to do this after you make any changes insidethe jni
folder.Your project should now compile, though it will not work yet. You must first configure your gamein the Google Play Console.
Step 2: Set up the game in the Google Play Console
Create an entry for your game in the Google Play Console. This enables Games services for yourapplication, and creates an OAuth 2.0 client ID, if you don't already have one.
Dev C++ Game Code
- Create an entry for your game by following the steps described inSetting Up Google Play Games Services.
- In
AndroidManifest.xml
, change thepackage
attribute of the<manifest>
tag to thepackage name you chose when setting up the Google Play Console. You may have to fix some referencesthroughout the project after making this change (particularly to the generatedR
class). - Open
res/values/ids.xml
and place your App ID there. Note that the App ID is not the same asthe client ID; it is the number next to the name of your game in the Game Details page ofthe Google Play Console.
Step 3: Run the sample
In order to run the sample you will need a physical Android device or an emulator withGoogle Play services installed:
- Run
ndk-build
to compile the native code. - In Eclipse, click Run > Run As > Android Application and run the sample on your device.
- When the sample opens, tap anywhere on the scren. You should see a Google Play Games logoappear. If you have correctly configured your app, you will be prompted to sign in.
Optional: Building Automatically with Eclipse
The following steps show you how to configure Eclipse to automatically run
ndk-build
when youmake changes to files in the jni
folder.- Right-click the MinimalistActivity project and click Properties. In the Properties window,select the Builders pane.
- Click New to add a new Builder and select Program then click OK.
- In the Name field, enter 'NDK Builder'.
- Under Location click Browse File System and navigate to the
NDK_ROOT
directory andselect thendk-build
command. - Under Working Directory click Browse Workspace and select the MinimalistActivityproject folder.
- Click the Refresh tab. Make sure the Refresh resources upon completion box is checked.
- Select the Specific resources radio button and then click Specify Resources. In theresulting dialog, select the
jni
folder under MinimalActivity. - Click Apply and then OK to finish creating your Builder.
C Google Search
Now every time you edit a file within the
jni
folder, Eclipse will run ndk-build
and print theoutput to the Eclipse Console.