Hide
Google Drive Android API

Getting Started

Before you can begin developing your Drive application, you need to download the Android and Google play Services SDKs and get an Android certificate, as described in the following sections.

Overview

Creating a new Android application that uses the Google Drive Android API requires several steps. Many of these steps only have to be perfomed once. The overall process of making a Drive-enabled Android application is as follows:

  1. Install the Android SDK.
  2. Download and configure the Google Play services SDK, which includes the Google Drive Android API.
  3. Register your application. To do this, you need to register a project in the Google Developers Console and get a signing certificate for your app.
  4. Add the required settings to your application's manifest.
  5. Add Drive services to your application. The easiest way to begin is by creating a file.

You may wish to begin by looking at some sample code, some of which is also included with the Google Play services SDK.

Install the Android SDK

As a prerequisite, you need to install the Android SDK. See Get the Android SDK.

Install and configure the Google Play services SDK

You need an Android project for your app before you can complete the steps in this section. If you haven't yet created an Android application, you can follow the tutorial Building Your First App.

The Google Drive Android API is distributed as part of the Google Play services SDK. You can download the Google Play services SDK via the Android SDK Manager. For detailed instructions, see the Google Play services SDK documentation.

Get an Android certificate and register your application

If you haven't already registered your application with the Google Developers Console, then set up a project and application in the Developers Console. The system guides you through the process of choosing or creating a project and registering a new application, and it automatically activates the API for you.

If you've already registered your application with the Developers Console, then follow this procedure instead:

In a terminal, run the Keytool utility to get the SHA1 fingerprint for your digitally signed .apk file's public certificate.
keytool -exportcert -alias androiddebugkey -keystore path-to-debug-or-production-keystore -list -v

The Keytool prints the fingerprint 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[1]:
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, which is highlighted in the example above.

Next, create credentials appropriate to your project in the Google Developers Console:

  1. Go to the Google Developers Console.
  2. Select a project, or create a new one.
  3. In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the Drive API.
  4. In the sidebar on the left, select Credentials.
  5. Select one of the following options:

    • If your application needs to submit authorized requests:

      1. Under OAuth, click Create new Client ID.
      2. Select Installed application and Android.
      3. In the Package name field, enter your Android app's package name.
      4. Paste the SHA1 fingerprint into the form where requested.
      5. Click Create Client ID.
    • If your application only needs to make API calls that do not require authorization:

      1. Under Public API access, click Create new Key.
      2. Select Android key.
      3. Paste the SHA1 fingerprint into the form where requested.
      4. After the fingerprint, type a semicolon and then enter your Android app's package name.
      5. Click Create.

Create a file in Google Drive

Now you're ready to authorize your application, create a file, and test your app.