Google Cloud Platform
Cloud Tools for Android Studio

Add an App Engine Module

Android Studio provides several types of App Engine 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.

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.

  3. Select Google Cloud Module from the list and then click Next.

  4. Select the desired backend type; for example choose App Engine Java Endpoints Module, and then supply the remaining information in the New Google Cloud Module form:

    Enter module parameters
    1. Supply a module name for your backend; this name will be displayed and used in your Android Studio project.

    2. Supply a package name. This package name will be used for all classes imported from this template.

    3. Select the client module (containing your Android app) in this project. This module will be automatically set up to have the right compile and build dependencies to be able to call your newly generated backend.

    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.

In particular, a new Gradle module with your specified module/package name has been added to your project containing your new backend. All of the required dependencies/permissions have been automatically set up for you.

Using the App Engine backend modules

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 enhancing the backend module 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.