Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Android Studio Backend Templates

The Google Cloud Platform provides backends that can automatically scale up to handle millions of users and that are entirely managed for you, eliminating the need to purchase, configure, maintain or administer servers. Examples of successful Android apps using Google Cloud Platform include Snapchat and Pulse .

Android Studio makes it easy to add a Google Cloud Platform backend to your Android project. You simply choose the type of backend you want and Android Studio adds the required code and dependencies to your project for a functioning, runnable backend that you can easily extend with the features you want, such as data storage.

Android Studio lets you run and test the backend locally and debug it along with your Android app that uses the backend. When you're finished developing and are ready to deploy, you can use Android Studio to deploy your backend to so it can be accessed by users of your app.

Requirements

The Google Cloud Platform backends feature requires the Java 7 SDK. You can check the SDK version used by your project in Android Studio by navigating to File > Project Structure ; the Java version currently being used is displayed in the Project SDK pulldown.

Types of backend templates available

Android Studio provides several types of backend templates for you to choose from:

Backend Type Description
App Engine Java Servlet Module Uses a standard App Engine Java servlet , requires the Android client app to build requests and send data using httpClient ; OAuth is not supported.
App Engine Java Endpoints Module Uses Google Cloud Endpoints , allows your Android client app to make direct API calls to the backend; OAuth 2.0 support is built-in.
App Engine Backend with Google Cloud Messaging This is similar to App Engine Java Endpoints Module but with the addition of Google Cloud Messaging (GCM) support. GCM lets you provide features such as push notifications to your Android app.

We expect that most Android developers will use either the Endpoints backend or the Endpoints backend with GCM due to OAuth support and the simpler method of accessing the backend.

Choosing a backend template

In Android Studio, you select the templates as follows:

  1. Start Android Studio and open the project for the Android app that needs the new backend.

  2. Right-click on your project and select New > Module .

    Add Backend

  3. Select the desired backend type from the list; for example select App Engine Java Endpoints Module , then click Next :

    Select Endpoints Backend

  4. Supply the following information in the New Module form:

    New Module Form

    1. Supply a module name for your backend; this name will be displayed and used in your Android Studio project. If you are adding an existing backend API, you might want to use the name of your API.
    2. Supply a package name. This package name will be used for all classes imported from this template.
    3. The client module is the one containing your Android app; it will be automatically selected, so you don't need to change anything here.
    4. Click Finish to generate the new backend.
  5. Select Tools > Android > Sync Project with Gradle Files to sync the project.

At this point, you've created a new buildable and runnable backend module for your Android Studio project and added it as an additional dependency in your project's settings.gradle file.

When you choose one of these template types, a new Gradle module with your specified module/package name will be added to your project containing your new backend. All of the required dependencies/permissions will be automatically set up for you.

Using the templates

For detailed instructions on how to connect your Android app to the backend, how to debug and test locally, and how to deploy, see the README at the appropriate GitHub repository:

Suggesting changes or enhance the templates

If you want to make suggestions to improve or enhance these templates, you are welcome to visit the GitHub repo and submit a pull request.

Support

If you have any problems adding these backends to your Android applications, you can find help using the following options:

For more information

For information on App Engine backends, Endpoints backends, and Google Cloud Messaging, visit the following:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.