Important: Chrome will be removing support for Chrome Apps on Windows, Mac, and Linux. Chrome OS will continue to support Chrome Apps. Additionally, Chrome and the Web Store will continue to support extensions on all platforms. Read the announcement and learn more about migrating your app.

Enable Play Services in Your ARC App

This article talks about how to enable Google Play Services in your ARC app.

Getting started

If your app uses Google+ sign-in, Google Cloud Messaging (GCM), contacts provider, or any of Google's OAuth 2 APIs, you need to set up a project on the Google Developers Console.

  1. Go to the Google Developers Console.
  2. Create a project. If you already have a project for your app, it is recommended to reuse it.
  3. Make sure the information in APIs & auth > Consent screen is correct.
    • Make sure Product name is set correctly. This is what users will see when granting your app permissions.
    • Make sure Email address is set correctly. This is where users will send feedback. Note that it is a dropdown menu that contains the email addresses of project owners. If the appropriate email address is not in the list, you can add the account as an owner in the Permissions section from the left navigation pane. Click Add Member, then make sure Is owner is selected.
    • Fill out the rest of the fields as necessary for your app.
  4. Navigate to APIs & auth > Credentials
    • Select Create new Client ID.
    • Create a Client ID for an Installed application of type Chrome application. Note: Do not use "Android" as the application type.
    • Paste in the ID assigned to your app from the Chrome Web Store. See Getting the app ID for more details.
  5. Copy the client ID assigned for your app and save it for later. It will look like:
    0123456789-randomstring.apps.googleusercontent.com
  6. Go to APIs & auth > APIs, turn on the APIs you need. For example:
    • Turn on Google Cloud Messaging for Chrome if your app uses GCM.
    • Turn on Contacts API if your app reads users' Google contacts from the contact provider.

Setting Client ID and Metadata

To allow your app to use the APIs you have enabled, paste the oauth client ID obtained above in the OAuth Client ID field in ARC Welder.

You also need to enable services explicitly using ARC-specific metadata. For example, to use GCM and Google+ sign-on, your Additional Metadata will look something like this:

{
  "usePlayServices": ["gcm", "plus"]
}

Available services are: ads, gcm, location, maps, plus.

Advanced: Local testing

When testing using these APIs, it is important that your app ID locally matches the app ID from the Chrome Web Store. To do this, get the Public key from the More info link in the Chrome Web Store Developer Dashboard. The public key will look like this:


-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwTjmSbBD9uFJEUR7jMYAL1sPX
qCNe7ljIb6dheKIYjkNtLt1YuiAw4Pul/PO+aYtm8tsbFnsNZ73AxhMX9aPxuzwl
Aak/iN6atxv7h8mwOg6HiHdxTDnOPrCv7fEud5aUFaq7sqDhiqwMpJoIOa1w7c29
9z3oXIrG1FGEkid1IQIDAQAB
-----END PUBLIC KEY-----

To use this public key for local testing, set Additional Metadata in ARC Welder to:

(merge this JSON with existing metadata from above):

{
  "crx_key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwTjmSbBD9uFJEUR7jMYAL1sPX
qCNe7ljIb6dheKIYjkNtLt1YuiAw4Pul/PO+aYtm8tsbFnsNZ73AxhMX9aPxuzwl
Aak/iN6atxv7h8mwOg6HiHdxTDnOPrCv7fEud5aUFaq7sqDhiqwMpJoIOa1w7c29
9z3oXIrG1FGEkid1IQIDAQAB"
}

Note: Remove line breaks and whitespace in the public key, this must be a contiguous string

If you have set the public key correctly, the next time you launch your app, it will be loaded with the same ID as your Chrome Web Store app. See chrome://extensions with Developer mode selected to confirm.

Choose the right Google Play Services version

The version of Google Play Services included in ARC will not always be the very latest version of Play Services that is available from Google Play and the Android SDK. If the Play Services library your app uses is newer than the Play Services in ARC, you will see a message from the ARC app to update Google Play Services.

In this case, you will need to downgrade your SDK in order to target Play Services in ARC. The Android SDK Manager always downloads the latest version of Play Services, so we suggest backing up previous SDKs before updating, so that you will be able to continue building APKs which work with ARC.