This quick-start sample application is an Android project that lets you get started with the Google+ platform in about 10 minutes. The app demonstrates using the Google+ Sign-In button, using SDK methods to list people that the user has circled, and making requests to other Google APIs.
The Google+ platform for Android has the following requirements:
- A physical device to use for developing and testing because Google Play services can only be installed on an emulator with an AVD that runs Google APIs platform based on Android 4.2.2 or higher.
- The latest version of the Android SDK, including the SDK Tools component. The SDK is available from the Android SDK Manager.
- Your project to compile against Android 2.3 (Gingerbread) or higher.
- The latest version of Android Studio.
Step 1: Enable the Google+ API
To authenticate and communicate with the Google+ APIs, you must create a
Google Developers Console
enable the Google+ API, create an OAuth 2.0
Client ID, and register your digitally signed
Go to the Google Developers Console
Note: Create a single project for the Android, iOS and web versions of your app.
Click Create Project:
In the Project name field, type in a name for your project,
- In the Project ID field, optionally type in a project ID for your project or use the one that the console has created for you. This ID must be unique world-wide.
- In the Project name field, type in a name for your project, such as
- Click the Create button and wait for the project to be created. Note: There may be short delay of up to 30 seconds before the project is created. Once the project is created, the name you gave it appears at the top of the left sidebar.
In the left sidebar, select APIs & auth (the APIs sub-item is
- Find the Google+ API and set its status to ON—notice that this action moves Google+ API to the top of the list; you can scroll up to see it.
In the sidebar under "APIs & auth", select Consent screen.
- Choose an Email Address and specify a Product Name.
In the left sidebar under "APIs & auth", select Credentials.
- Click Create a new Client ID—the Create Client ID dialog box appears, as shown further below.
- Select Installed application for the application type.
- Select Android as the installed application type.
Copy and paste the following
for this quick-start app into the Package name field:
In a terminal, run the the Keytool utility
to get the SHA-1 fingerprint of the certificate. For the
debug.keystore, the password is
keytool -exportcert -alias androiddebugkey -keystore <path-to-debug-or-production-keystore> -list -v
Keytool prints the fingerprint hash to the shell. For example:
$ keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v Enter keystore password: Type "android" if using debug.keystore Alias name: androiddebugkey Creation date: Aug 27, 2012 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate: Owner: CN=Android Debug, O=Android, C=US Issuer: CN=Android Debug, O=Android, C=US Serial number: 503bd581 Valid from: Mon Aug 27 13:16:01 PDT 2012 until: Wed Aug 20 13:16:01 PDT 2042 Certificate fingerprints: MD5: 1B:2B:2D:37:E1:CE:06:8B:A0:F0:73:05:3C:A3:63:DD SHA1: D8:AA:43:97:59:EE:C5:95:26:6A:07:EE:1C:37:8E:F4:F0:C8:05:C8 SHA256: F3:6F:98:51:9A:DF:C3:15:4E:48:4B:0F:91:E3:3C:6A:A0:97:DC:0A:3F:B2:D2:E1:FE:23:57:F5:EB:AC:13:30 Signature algorithm name: SHA1withRSA Version: 3
Copy the SHA1 fingerprint hash from your terminal. The example above highlights where to find it.
- Paste the SHA-1 fingerprint hash into the Signing certificate fingerprint field shown below.
To activate interactive posts, enable the Deep Linking
- Click the Create client ID button.
You are done enabling the Google+ API for your app.
Step 2: Run the Google+ quick-start sample app
Clone or download the Android Google+ quickstart Git repository.
git clone https://github.com/googleplus/gplus-quickstart-android.git
Launch Android Studio.
- Select File > Import Project.
- Navigate to the path to your Android quickstart directory and select
- Connect your physical device to your machine by USB. Google
Play Services requires a physical device and will not
function on an emulator for Android platforms prior to 4.2.2.
- Select Run > Run 'app' to test the quick-start sample app. Choose
your device if prompted. The sample app will launch on your physical device.
Step 3: Verify that the project is configured correctly
Now that the quick-start app is running, you can verify that it is configured correctly by following these steps:
- In the quick-start app, click Sign in.
- If you have more than one account on your device, you should see a dialog to choose which account to use to sign in to the app.
- Choose an account and click OK.
- An authorization screen should display. If you do not see a screen that appears similar to the following screenshot, then your API console configuration does not match your running app. This is typically due to a mismatch between either the package ID or the SHA1 hash.
- The authorization dialog did not display when running the quick-start app
- Verify that your package name matches the value that you entered
in the APIs console. For the sample, the package name should be
- Verify that your SHA1 hash matches your API console project.
- Check that your
debug.keystorefile has not expired by examining the output of the keytool command. The line that begins "Valid from." If the keystore file is expired, delete the
debug.keystorefile and rebuild the app to create a new
debug.keystorefile. Run the keytool command again to generate a new SHA1 hash then create a new client ID with the new SHA1 hash.
- If you are seeing
ConnectionResult.getErrorCode() = 4when trying to connect, ensure that the consent screen is configured and saved.
- Verify that your package name matches the value that you entered in the APIs console. For the sample, the package name should be
Now that you have run the quick-start sample app, use the following to start integrating Google+ features into your own app:
Otherwise, you can proceed to integrate the
GoogleApiClient into your
Learn more about the Google+ features you can add to your app: