Generating a Client Library for Android

This page describes how to generate a client library from your backend API. Your Android app using this client library to call the API.

Before you begin

Before you can generate a client library, you must have already annotated the backend API code. For an example of how to annotate your backend API code, see the backend API tutorial.

Generating a client library for an Android app

To generate a client library for an Android app:

Android Studio

If you use Android Studio and Cloud Tools for Android Studio to build your app and backend API, Android Studio automatically generates the client libraries and updates them if you make changes to your backend API code.

For instructions on how to add a backend API to your app in Android Studio, see Add a Cloud Endpoints Module in the Cloud Tools for Android Studio documentation.


If you created your backend API in a Maven project using the App Engine Maven artifacts as described in the backend API tutorial, you can generate the client library as follows:

  1. Invoke the following command in the directory containing your project pom.xml file:

  2. mvn appengine:endpoints_get_client_lib
  3. Locate the generated client library source directory and files, which are inside your project root directory at this subdirectory location: /target/endpoints-client-libs/[yourProjectName] and change directory to this location.

  4. Invoke Maven to build the client library:

    mvn install

  5. This builds the required class files and creates the JAR file you need to add to your client project. The JAR file is located inside your current directory at this subdirectory location:


  6. Add the client library JAR to the Android app as described in Calling Endpoints from an Android App.

Endpoints CLI

The following instructions demonstrate how to use the Endpoints command-line tool to generate a Gradle client bundle from a Maven project. If you use Eclipse, the project layout will be slightly different.

If you are running the commands from Windows, use endpoints.cmd instead of and omit the continuation character "\" and carriage returns in the command.

  1. If you haven't already done so, build the backend API.

  2. Invoke the Endpoints command line tool similarly to the following:

    appengine-java-sdk-x.x.x/bin/ get-client-lib \
        --war=target/helloendpoints-1.0-SNAPSHOT \
        -bs gradle

    where we are building a Gradle bundle and where target/helloendpoints-1.0-SNAPSHOT is the relative or absolute path to the the target build directory containing WEB-INF/appengine-web.xml and the compiled backend classes.

    Compiled classes

  3. When successful, the tool displays a message similar to:

    INFO: Successfully processed /usr/local/directory/helloendpoints/target/helloendpoints-1.0-SNAPSHOT/WEB-INF/appengine-web.xml
    API client library written to ./

    The client library bundle is written to the current directory unless you specify some other output directory using the --output option.

  4. Add the client library JAR to the Android app as described in Calling Endpoints from an Android App.

Client Library Bundles

This bundle is the Java library be used in your client to call the backend API; it provides your client with all of the Google API client capabilities, including OAuth.

What's Next?