This page describes migrating an existing Android Cloud Endpoints version 1.0 app to Endpoints Frameworks for App Engine. Note that this page refers to Endpoints version 1.0 as Endpoints Frameworks version 1.0 and new Endpoints Frameworks for App Engine as Endpoints Frameworks version 2.0.
Benefits
The new framework brings a number of benefits, including:
- Reduced request latency
- Better integration with App Engine features, such as custom domains.
- Official support for Guice configurations
- Optionally, new API management features
Endpoints Frameworks version 2.0 doesn't affect the interfaces to your API. Existing clients continue to work after migration without any client-side code changes.
Migrating Android multi-module projects to Endpoints Frameworks version 2.0
The following steps guide you through moving Android Studio Endpoints Frameworks version 1.0 projects to Endpoints Frameworks version 2.0. The guide migrates an Android Studio project with a Endpoints module.
Task list
Use the following high-level task list as you work through the migration guide. This migration guide assumes you have an existing Android project using a Google Cloud module.
- Before you begin.
- Setup the Google Cloud CLI.
- Optional: Download the sample code.
- Migrate to Endpoints Frameworks version 2.0.
- Deploy your backend module.
- Generate client libraries.
Before you begin
- Install Android Studio.
- Install Android SDK 26+.
- Install the gcloud CLI.
Set up the gcloud CLI
To setup the gcloud CLI:
Initialize the gcloud CLI:
gcloud init
Use Application Default Credentials:
gcloud auth application-default login
Install the
app-engine-java
component:gcloud components install app-engine-java
Optional: Download the sample code
To clone the legacy
and v2
sample projects from GitHub:
Clone the sample repository to your local machine:
git clone https://github.com/GoogleCloudPlatform/android-docs-samples
Change to the directory containing the sample code for
legacy
andv2
:cd android-docs-samples/endpoints-frameworks/
Migrate to Endpoints Frameworks version 2.0
Update the build.gradle
file
Endpoints Frameworks version 2.0 dependencies use Guava 19 and Android
Gradle build plugin com.android.tools.build:gradle:2.3.3
uses Guava 18. Add
Guava 19 to the build script dependencies closure of the build.gradle
to
override this transitive dependency.
Legacy
v2
Update the app/build.gradle
file
In Endpoints version 1.0, you used the Gradle plugin,
gradle-appengine-plugin
, to generate an API Discovery Document. In
Endpoints Frameworks version 2.0, you use the
endpoints-framework-gradle-plugin
to generate a Discovery Document.
This build script uses the client-side plugin,
com.google.cloud.tools.endpoints-framework-client
.
Legacy
v2
Update the backend/build.gradle
file
The App Engine standard environment Gradle tooling was updated.
Endpoints Frameworks version 1.0 projects used the
gradle-appengine-plugin
in com.google.appengine
, and
Endpoints Frameworks version 2.0 projects
use appengine-gradle-plugin
.
This build script uses the server-side plugin,
com.google.cloud.tools.endpoints-framework-server
.
Legacy
v2
Update the web.xml
file
In Endpoints Frameworks version 2.0, the servlet-class changed from
SystemServiceServlet
to EndpointsServlet
.
The URL pattern was updated from /_ah/spi/*
to /_ah/api/*
.
Legacy
v2
Rebuild project
Finally, use the Android Studio build list to clean and rebuild the Android Studio project with the new dependencies.
Deploy your backend module
The new Gradle App Engine plugin is now used to deploy the backend
module by using the following Gradle task while in the backend
module:
gradle appengineDeploy
Generate client libraries
To generate client libraries, use the following Gradle task while in the
backend
module:
gradle endpointsClientLibs
Learn more about the available tasks for the Endpoints Frameworks Gradle plugin.
Adding Endpoints API management
Endpoints Frameworks version 2.0 also lets you turn on API management features, including:
- API key management
- API sharing
- User authentication
- API metrics
- API logs
To get started using these and other Cloud Endpoints Frameworks 2.0 features, go to the Java page about Endpoints Frameworks for App Engine.