diff --git a/GcmEndpoints/README.md b/GcmEndpoints/README.md index 2735ef6..122e05f 100644 --- a/GcmEndpoints/README.md +++ b/GcmEndpoints/README.md @@ -1,177 +1,8 @@ "App Engine Backend with Google Cloud Messaging" Template =========================================== -[Google Cloud Messaging](http://developer.android.com/google/gcm) (GCM) is a service that allows you to send push notifications from your server to your users' Android devices, and also to receive messages from devices on the same connection. The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device. +This repository has been deprecated. -This backend template employs [Google Cloud Endpoints](https://developers.google.com/appengine/docs/java/endpoints) to define a RESTful API which registers Android devices with your GCM server and allows you to send string messages to registered devices. After defining this API, strongly-typed client libraries are generated automatically and can be called from your Android app, as described below. +Starting in Android Studio 3.0, creation of App Engine backends has been removed. -# 1. Adding a backend in Android Studio - -This guide builds on top of the [GCM sample Quickstart app](https://github.com/googlesamples/google-services/tree/master/android/gcm). If you already have an existing application, then you can reference the Quickstart app as a guide to setting the GCM client code. - -To add the backend to your existing Android app from the GCM backend template, open [Android Studio](https://developer.android.com/sdk/installing/studio.html) and navigate to "File → New Module..." or right-click on your project and choose "New → Module". - -![New → Module](/doc/img/add-app-engine-backend-menu-scaled.png) - -In the "New Module" wizard that appears, choose "Google Cloud Module": - -![Add App Engine Backend Choose Module](/doc/img/choose_module.png) - -Then choose "App Engine Backend with Google Cloud Messaging". - -![App Engine GCM Module](/doc/img/gcm2.png) - -Enter the module/package names for your new backend, and choose the "client" module in the project which contains your Android app. The client module will be set up to call your newly generated backend. The module name which you've entered above (marked with red **1**) will be used in your Android Studio project. The package name (marked with red **2**) will be used for all classes imported from this template and (reversed) for [Endpoints API namespaces](https://developers.google.com/appengine/docs/java/endpoints/annotations#apinamespace). In turn, Endpoints API namespaces will be used to derive the name of the autogenerated Android client libraries. This ensures that the names of generated client libraries will match your package name. - -![Added "GcmEndpoints" backend. Red numbers 1 and 2 indicate that the module name and the package names came from "New App Engine Module" dialog](/doc/img/added-backend-gcm.png) - -## 1.1. Debugging the backend locally - -As soon as the backend module is added to your project and Gradle sync finishes, a new run configuration with your backend's module name should be created: - -![Created run configuration](/doc/img/run-configuration.png) - -Rebuild your project (via "Build → Rebuild Project") and launch this run configuration. It will invoke `appengineRun` task in [Gradle plug-in for App Engine](https://github.com/GoogleCloudPlatform/gradle-appengine-plugin), which in turn will start the local App Engine [Java development server](https://developers.google.com/appengine/docs/java/tools/devserver). - -Navigate to [http://localhost:8080](http://localhost:8080). You should see the following page: - -!["HelloWorld" backend running in local Java development server](/doc/img/devappserver-gcm.png) - -# 2. Connecting your Android app to the backend - -## 2.1. Obtaining Google Cloud Messaging API key - -To test the application, you need a Google Cloud Messaging API key. Follow the [instructions](https://developers.google.com/cloud-messaging/android/client) to create a `google-services.json` configuration file and API key. Open the `/src/main/webapp/WEB-INF/appengine-web.xml` file (it should have been opened by default when you generated the backend), and copy the generated API key into `appengine-web.xml` file, replacing -```xml - -``` -with -```xml - -``` - -## 2.2. Registering devices with Google Cloud Messaging backend - -Before any messages can be sent from a Google Cloud Messaging backend to the devices, these devices need to be registered with a GCM backend. - -When you added this backend module to your project, the [required permissions, needed by Google Cloud Messaging](http://developer.android.com/google/gcm/client.html#manifest) have been added into the Android manifest of your app, and the required build dependencies have been added to your app's `build.gradle` file. - -Furthermore, a `RegistrationEndpoint` [Cloud Endpoints API](https://developers.google.com/appengine/docs/java/endpoints/) has been automatically generated for you, so that you could start calling this endpoint from your Android app to register devices with your new Google Cloud Messaging backend. - -Set up your [Google Cloud Messaging Client](https://developers.google.com/cloud-messaging/android/client). Follow the guide to obtain a registration token, register the user's device with your new backend, and set up the listener services to show push notifications from the GCM backend. - -To send your newly obtained GCM registration token to the server, use the following code snippet which you should invoke from the `RegistrationIntentService` you created when setting up the client: - -```java - private void sendRegistrationToServer(String token) throws IOException { - Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(), - new AndroidJsonFactory(), null) - // Need setRootUrl and setGoogleClientRequestInitializer only for local testing, - // otherwise they can be skipped - .setRootUrl("http://10.0.2.2:8080/_ah/api/") - .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { - @Override - public void initialize(AbstractGoogleClientRequest abstractGoogleClientRequest) - throws IOException { - abstractGoogleClientRequest.setDisableGZipContent(true); - } - }); - Registration regService = builder.build(); - regService.register(token).execute(); - } -``` - -## 2.3. Testing device registration in an emulator - -If you have added a `RegistrationIntentService` invocation to one of your Android app activities (as demonstrated in the Quickstart app), and set up the `google-services.json` configuration file containing your Google Developers Console project number, you are ready to test the device registration with your backend locally. - -First, make sure that your Android Virtual Device is using Google APIs System Image as illustrated in the screenshot below. - -![Android Virtual Device configuration containing Google APIs System Image Target](/doc/img/avd-manager-google-api-image.png) - -Next, launch your backend locally as described in section 1.1 and ensure that you can access it via [http://localhost:8080](http://localhost:8080). If you can access the backend locally, change the run configuration back to your Android app and run the Android emulator. - -You should see the following in your GCM Quickstart app: - -![Emulator successfully registered with "GcmEndpoints" backend](/doc/img/emulator-gcm.png) - -## 2.3.1. Testing device registration on a physical device - -Testing on a physical device with a local development server requires minor changes to your configuration. - -1. You must make your development server accessible to the network by setting it to listen to external connections. You can do this by editing the build.gradle for the backend project and setting the httpAddress. - ```gradle - appengine { - .... - httpAddress = "0.0.0.0" - .... - } - ``` - -1. You must also change the endpoint root url to point to your computer's ip address when creating the endpoint . - ```java - Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(), - new AndroidJsonFactory(), null) - .setRootUrl("http://:8080/_ah/api/") - .... - ``` -## 2.4. Showing push notifications from GCM backend - -You should now be set up to receive push notifications coming from the generated backend. To test this out, ensure your GCM backend is running locally as described in section 1.1, enter a test message, and send: - -![Send message from GCM backend](/doc/img/backend-message.png) - -You should see a notification arrive in your device emulator: - -![Receive notification in device emulator](/doc/img/backend-notification.png) - -## 2.5. Deploying the backend live to App Engine - -If your backend is working locally, you can deploy it to Google App Engine. - -1. Stop the backend, if it is running locally, by selecting -**Run** > **Stop**. - -2. Run **Build** > **Deploy Module to App Engine**. - -![Deploy module to App Engine](/doc/img/deploy-addacct.png) - -3. In the **Deploy to App Engine** dialog, select your module. From the **Deploy To:** dropdown list, choose "Click here to create a new Google Developers Console project." This will open [Google Developers Console](https://console.developers.google.com) - - + If you are running this task for the first time, you will be prompted to -sign-in with your Google Account. Choose an account and sign in.
- -4. Create a new project and switch back to the **Deploy to App Engine** dialog in Android Studio. - -5. This would probably be a good time to update your `src/main/webapp/WEB-INF/appengine-web.xml` file's `` property and replace `myApplicationId` with the ID of the project that you just created. This will be important if you try to deploy from the command line. - -6. Click the Refresh button ![Deploy module to App Engine](/doc/img/refresh.png) in the bottom right corner of the **Deploy To:** dropdown list and then select the project you just created. - -7. Click **Deploy**. You can monitor the status of your deployment in the Android Studio console. - -## 2.6. Testing against a deployed backend - -Once you have deployed your backend to App Engine, you can connect your Android app to it by modifying the `RegistrationIntentService` class explained in section 2 above. In particular, replace the lines -```java -Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(), - new AndroidJsonFactory(), null) - // Need setRootUrl and setGoogleClientRequestInitializer only for local testing, - // otherwise they can be skipped - .setRootUrl("http://10.0.2.2:8080/_ah/api/") - .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { - @Override - public void initialize(AbstractGoogleClientRequest abstractGoogleClientRequest) - throws IOException { - abstractGoogleClientRequest.setDisableGZipContent(true); - } - }); -``` -with these lines -```java -Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(), - new AndroidJsonFactory(), null) - .setRootUrl("https://android-app-backend.appspot.com/_ah/api/"); -``` -where `android-app-backend` corresponds to your own Project ID created in section 2.5. - -At this point you should be all set to run your Android app in an emulator or on the physical device, and successfully communicate with your new App Engine backend! +Please see https://cloud.google.com/tools/android-studio/docs/ for more. diff --git a/GcmEndpoints/globals.xml.ftl b/GcmEndpoints/globals.xml.ftl deleted file mode 100644 index 57e5e0f..0000000 --- a/GcmEndpoints/globals.xml.ftl +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/GcmEndpoints/recipe.xml.ftl b/GcmEndpoints/recipe.xml.ftl deleted file mode 100644 index 4ca05b5..0000000 --- a/GcmEndpoints/recipe.xml.ftl +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/GcmEndpoints/root/build.gradle.ftl b/GcmEndpoints/root/build.gradle.ftl deleted file mode 100644 index 58e31d4..0000000 --- a/GcmEndpoints/root/build.gradle.ftl +++ /dev/null @@ -1,42 +0,0 @@ -// If you would like more information on the gradle-appengine-plugin please refer to the github page -// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.google.appengine:gradle-appengine-plugin:${appEngineVersion}' - } -} - -repositories { - jcenter(); -} - -apply plugin: 'java' -apply plugin: 'war' -apply plugin: 'appengine' - -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 - -dependencies { - appengineSdk 'com.google.appengine:appengine-java-sdk:${appEngineVersion}' - compile 'com.google.appengine:appengine-endpoints:${appEngineVersion}' - compile 'com.google.appengine:appengine-endpoints-deps:${appEngineVersion}' - compile 'javax.servlet:servlet-api:2.5' - compile 'com.googlecode.objectify:objectify:5.1.9' - compile 'com.ganyo:gcm-server:1.0.2' -} - -appengine { - downloadSdk = true - appcfg { - oauth2 = true - } - endpoints { - getClientLibsOnBuild = true - getDiscoveryDocsOnBuild = true - } -} diff --git a/GcmEndpoints/root/settings.gradle.ftl b/GcmEndpoints/root/settings.gradle.ftl deleted file mode 100644 index 08ccf84..0000000 --- a/GcmEndpoints/root/settings.gradle.ftl +++ /dev/null @@ -1 +0,0 @@ -include ':${moduleName}' \ No newline at end of file diff --git a/GcmEndpoints/root/src/main/MessagingEndpoint.java.ftl b/GcmEndpoints/root/src/main/MessagingEndpoint.java.ftl deleted file mode 100644 index b954ab8..0000000 --- a/GcmEndpoints/root/src/main/MessagingEndpoint.java.ftl +++ /dev/null @@ -1,89 +0,0 @@ -/* - For step-by-step instructions on connecting your Android application to this backend module, - see "App Engine Backend with Google Cloud Messaging" template documentation at - https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/GcmEndpoints -*/ - -package ${packageName}; - -import com.google.android.gcm.server.Constants; -import com.google.android.gcm.server.Message; -import com.google.android.gcm.server.Result; -import com.google.android.gcm.server.Sender; -import com.google.api.server.spi.config.Api; -import com.google.api.server.spi.config.ApiNamespace; - -import java.io.IOException; -import java.util.List; -import java.util.logging.Logger; -import javax.inject.Named; - -import static ${packageName}.OfyService.ofy; - -/** - * An endpoint to send messages to devices registered with the backend - * - * For more information, see - * https://developers.google.com/appengine/docs/java/endpoints/ - * - * NOTE: This endpoint does not use any form of authorization or - * authentication! If this app is deployed, anyone can access this endpoint! If - * you'd like to add authentication, take a look at the documentation. - */ -@Api( - name = "messaging", - version = "v1", - namespace = @ApiNamespace( - ownerDomain = "${endpointOwnerDomain}", - ownerName = "${endpointOwnerDomain}", - packagePath="${endpointPackagePath}" - ) -) -public class MessagingEndpoint { - private static final Logger log = Logger.getLogger(MessagingEndpoint.class.getName()); - - /** Api Keys can be obtained from the google cloud console */ - private static final String API_KEY = System.getProperty("gcm.api.key"); - - /** - * Send to the first 10 devices (You can modify this to send to any number of devices or a specific device) - * - * @param message The message to send - */ - public void sendMessage(@Named("message") String message) throws IOException { - if(message == null || message.trim().length() == 0) { - log.warning("Not sending message because it is empty"); - return; - } - // crop longer messages - if (message.length() > 1000) { - message = message.substring(0, 1000) + "[...]"; - } - Sender sender = new Sender(API_KEY); - Message msg = new Message.Builder().addData("message", message).build(); - List records = ofy().load().type(RegistrationRecord.class).limit(10).list(); - for(RegistrationRecord record : records) { - Result result = sender.send(msg, record.getRegId(), 5); - if (result.getMessageId() != null) { - log.info("Message sent to " + record.getRegId()); - String canonicalRegId = result.getCanonicalRegistrationId(); - if (canonicalRegId != null) { - // if the regId changed, we have to update the datastore - log.info("Registration Id changed for " + record.getRegId() + " updating to " + canonicalRegId); - record.setRegId(canonicalRegId); - ofy().save().entity(record).now(); - } - } else { - String error = result.getErrorCodeName(); - if (error.equals(Constants.ERROR_NOT_REGISTERED)) { - log.warning("Registration Id " + record.getRegId() + " no longer registered with GCM, removing from datastore"); - // if the device is no longer registered with Gcm, remove it from the datastore - ofy().delete().entity(record).now(); - } - else { - log.warning("Error when sending message : " + error); - } - } - } - } -} diff --git a/GcmEndpoints/root/src/main/OfyService.java.ftl b/GcmEndpoints/root/src/main/OfyService.java.ftl deleted file mode 100644 index 256fe17..0000000 --- a/GcmEndpoints/root/src/main/OfyService.java.ftl +++ /dev/null @@ -1,25 +0,0 @@ -package ${packageName}; - -import com.googlecode.objectify.Objectify; -import com.googlecode.objectify.ObjectifyFactory; -import com.googlecode.objectify.ObjectifyService; - -/** - * Objectify service wrapper so we can statically register our persistence classes - * More on Objectify here : https://code.google.com/p/objectify-appengine/ - * - */ -public class OfyService { - - static { - ObjectifyService.register(RegistrationRecord.class); - } - - public static Objectify ofy() { - return ObjectifyService.ofy(); - } - - public static ObjectifyFactory factory() { - return ObjectifyService.factory(); - } -} diff --git a/GcmEndpoints/root/src/main/RegistrationEndpoint.java.ftl b/GcmEndpoints/root/src/main/RegistrationEndpoint.java.ftl deleted file mode 100644 index c3c8fed..0000000 --- a/GcmEndpoints/root/src/main/RegistrationEndpoint.java.ftl +++ /dev/null @@ -1,90 +0,0 @@ -/* - For step-by-step instructions on connecting your Android application to this backend module, - see "App Engine Backend with Google Cloud Messaging" template documentation at - https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/GcmEndpoints -*/ - -package ${packageName}; - -import com.google.api.server.spi.config.Api; -import com.google.api.server.spi.config.ApiMethod; -import com.google.api.server.spi.config.ApiNamespace; -import com.google.api.server.spi.response.CollectionResponse; - -import java.util.List; -import java.util.logging.Logger; -import javax.inject.Named; - -import static ${packageName}.OfyService.ofy; - -/** - * A registration endpoint class we are exposing for a device's GCM registration id on the backend - * - * For more information, see - * https://developers.google.com/appengine/docs/java/endpoints/ - * - * NOTE: This endpoint does not use any form of authorization or - * authentication! If this app is deployed, anyone can access this endpoint! If - * you'd like to add authentication, take a look at the documentation. - */ -@Api( - name = "registration", - version = "v1", - namespace = @ApiNamespace( - ownerDomain = "${endpointOwnerDomain}", - ownerName = "${endpointOwnerDomain}", - packagePath="${endpointPackagePath}" - ) -) -public class RegistrationEndpoint { - - private static final Logger log = Logger.getLogger(RegistrationEndpoint.class.getName()); - - /** - * Register a device to the backend - * - * @param regId The Google Cloud Messaging registration Id to add - */ - @ApiMethod(name = "register") - public void registerDevice(@Named("regId") String regId) { - if(findRecord(regId) != null) { - log.info("Device " + regId + " already registered, skipping register"); - return; - } - RegistrationRecord record = new RegistrationRecord(); - record.setRegId(regId); - ofy().save().entity(record).now(); - } - - /** - * Unregister a device from the backend - * - * @param regId The Google Cloud Messaging registration Id to remove - */ - @ApiMethod(name = "unregister") - public void unregisterDevice(@Named("regId") String regId) { - RegistrationRecord record = findRecord(regId); - if(record == null) { - log.info("Device " + regId + " not registered, skipping unregister"); - return; - } - ofy().delete().entity(record).now(); - } - - /** - * Return a collection of registered devices - * - * @param count The number of devices to list - * @return a list of Google Cloud Messaging registration Ids - */ - @ApiMethod(name = "listDevices") - public CollectionResponse listDevices(@Named("count") int count) { - List records = ofy().load().type(RegistrationRecord.class).limit(count).list(); - return CollectionResponse.builder().setItems(records).build(); - } - - private RegistrationRecord findRecord(String regId) { - return ofy().load().type(RegistrationRecord.class).filter("regId", regId).first().now(); - } - -} diff --git a/GcmEndpoints/root/src/main/RegistrationRecord.java.ftl b/GcmEndpoints/root/src/main/RegistrationRecord.java.ftl deleted file mode 100644 index 28f38a5..0000000 --- a/GcmEndpoints/root/src/main/RegistrationRecord.java.ftl +++ /dev/null @@ -1,27 +0,0 @@ -package ${packageName}; - -import com.googlecode.objectify.annotation.Entity; -import com.googlecode.objectify.annotation.Id; -import com.googlecode.objectify.annotation.Index; - -/** The Objectify object model for device registrations we are persisting */ -@Entity -public class RegistrationRecord { - - @Id - Long id; - - @Index - private String regId; - // you can add more fields... - - public RegistrationRecord() {} - - public String getRegId() { - return regId; - } - - public void setRegId(String regId) { - this.regId = regId; - } -} \ No newline at end of file diff --git a/GcmEndpoints/root/src/webapp/appengine-web.xml.ftl b/GcmEndpoints/root/src/webapp/appengine-web.xml.ftl deleted file mode 100644 index a6e1fbe..0000000 --- a/GcmEndpoints/root/src/webapp/appengine-web.xml.ftl +++ /dev/null @@ -1,22 +0,0 @@ - - - ${appId} - 1 - true - - - - - - - - - \ No newline at end of file diff --git a/GcmEndpoints/root/src/webapp/index.html.ftl b/GcmEndpoints/root/src/webapp/index.html.ftl deleted file mode 100644 index 21e9927..0000000 --- a/GcmEndpoints/root/src/webapp/index.html.ftl +++ /dev/null @@ -1,123 +0,0 @@ - - - - Hello, Google Cloud Messaging! - - - - - - - - -
- -
- - -
-
-
-

Hello, Google Cloud Messaging!

-

Enter your message below and press "Send Message" button to send it over Google Cloud Messaging to all registered devices.

-
-
- - - - -
-
-
-

If you need step-by-step instructions for connecting your Android application to this backend module, see "App Engine Backend with Google Cloud Messaging" template documentation.

-

- - For more information about Google App Engine for Java, check out the App Engine documentation.
- To learn more about Google Cloud Endpoints, see Cloud Endpoints documentation.
- Similarly, for more information about Google Cloud Messaging, see Cloud Messaging documentation.
- If you'd like to access your generated Google Cloud Endpoints APIs directly, see the Cloud Endpoints API Explorer. -
-

-
-
-
-
- - - - - - diff --git a/GcmEndpoints/root/src/webapp/logging.properties.ftl b/GcmEndpoints/root/src/webapp/logging.properties.ftl deleted file mode 100644 index 0c2ea51..0000000 --- a/GcmEndpoints/root/src/webapp/logging.properties.ftl +++ /dev/null @@ -1,13 +0,0 @@ -# A default java.util.logging configuration. -# (All App Engine logging is through java.util.logging by default). -# -# To use this configuration, copy it into your application's WEB-INF -# folder and add the following to your appengine-web.xml: -# -# -# -# -# - -# Set the default logging level for all loggers to WARNING -.level = WARNING diff --git a/GcmEndpoints/root/src/webapp/web.xml.ftl b/GcmEndpoints/root/src/webapp/web.xml.ftl deleted file mode 100644 index 49b872a..0000000 --- a/GcmEndpoints/root/src/webapp/web.xml.ftl +++ /dev/null @@ -1,27 +0,0 @@ - - - - ObjectifyFilter - com.googlecode.objectify.ObjectifyFilter - - - ObjectifyFilter - /* - - - SystemServiceServlet - com.google.api.server.spi.SystemServiceServlet - - services - ${packageName}.RegistrationEndpoint, ${packageName}.MessagingEndpoint - - - - SystemServiceServlet - /_ah/spi/* - - - - index.html - - \ No newline at end of file diff --git a/GcmEndpoints/template.xml b/GcmEndpoints/template.xml deleted file mode 100644 index 2d43153..0000000 --- a/GcmEndpoints/template.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/HelloEndpoints/README.md b/HelloEndpoints/README.md index 93214be..8bb6fa1 100644 --- a/HelloEndpoints/README.md +++ b/HelloEndpoints/README.md @@ -1,165 +1,8 @@ "App Engine Java Endpoints Module" Template =========================================== -This backend template employs [Google Cloud Endpoints](https://developers.google.com/appengine/docs/java/endpoints) to define a RESTful backend API from very simple annotations of the server-side Java code. Google Cloud Endpoints also provide automated Java object marshalling/unmarshalling to JSON, generation of strongly-typed client libraries that can be called from your Android app, built-in authentication support and so on. +This repository has been deprecated. -# 1. Adding a backend in Android Studio +Starting in Android Studio 3.0, creation of App Engine backends has been removed. -To add the backend to your existing Android app from this backend template, open Android Studio ([installation instructions](https://developer.android.com/sdk/installing/studio.html)) and navigate to "File → New Module..." or right-click on your project and choose "New → Module". - -![Tools → Google Cloud Tools → Add App Engine Backend](/doc/img/add-app-engine-backend-menu-scaled.png) - -In the "New Module" wizard that appears, choose "Google Cloud Module": - -![Add App Engine Backend Choose Module](/doc/img/choose_module.png) - -Then choose "App Engine Java Endpoints Module". - -![Tools → Google Cloud Tools → Add App Engine Backend](/doc/img/endpoints2.png) - -Enter the module/package names for your new backend, and choose the "client" module in your project which contains your Android app. The client module will be set up to call your newly generated backend. Module name which you've entered above (marked with red **1**) will be used in your Android Studio project. Package name (marked with red **2**) will be used for all classes imported from this template and (reversed) for [Endpoints API namespace](https://developers.google.com/appengine/docs/java/endpoints/annotations#apinamespace). In turn, Endpoints API namespace will be used to derive the name of the autogenerated Android client libraries, hence this ensures that the names of generated client libraries will match your package name. - -![Added "HelloWorld" backend. Red numbers 1 and 2 indicate that the module name and the package name came from "New App Engine Module" dialog](/doc/img/added-backend-endpoints.png) - -## 1.1. Debugging the backend locally - -As soon as the backend module is added to your project and Gradle sync finishes, a new run configuration with your backend's module name should be created: - -![Created run configuration](/doc/img/run-configuration.png) - -Rebuild your project (via "Build → Rebuild Project") and launch this run configuration. It will invoke `appengineRun` task in [Gradle plug-in for App Engine](https://github.com/GoogleCloudPlatform/gradle-appengine-plugin), which in turn will start the local App Engine [Java development server](https://developers.google.com/appengine/docs/java/tools/devserver). - -To ensure that your backend started successfully, navigate to [http://localhost:8080](http://localhost:8080). If everything went well, you should see the following page: - -!["HelloWorld" backend running in local Java development server](/doc/img/devappserver-endpoints.png) - -# 2. Connecting your Android app to the backend - -When you created a backend module, strongly-typed client libraries have been automatically generated for you. These client libraries are re-built together with your backend module. Furthermore, your Android app ("client") module has been set up to include compile dependencies to these generated client libraries, access internet and so on. - -To start sending requests to the added Cloud Endpoints backend API, you can use the following code snippet. In particular, this snippet illustrates how to create an [AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html) which makes the request to the backend and prints the incoming result string to a [toast](http://developer.android.com/guide/topics/ui/notifiers/toasts.html) in a given context: - -```java -class EndpointsAsyncTask extends AsyncTask, Void, String> { - private static MyApi myApiService = null; - private Context context; - - @Override - protected String doInBackground(Pair... params) { - if(myApiService == null) { // Only do this once - MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), - new AndroidJsonFactory(), null) - // options for running against local devappserver - // - 10.0.2.2 is localhost's IP address in Android emulator - // - turn off compression when running against local devappserver - .setRootUrl("http://10.0.2.2:8080/_ah/api/") - .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { - @Override - public void initialize(AbstractGoogleClientRequest abstractGoogleClientRequest) throws IOException { - abstractGoogleClientRequest.setDisableGZipContent(true); - } - }); - // end options for devappserver - - myApiService = builder.build(); - } - - context = params[0].first; - String name = params[0].second; - - try { - return myApiService.sayHi(name).execute().getData(); - } catch (IOException e) { - return e.getMessage(); - } - } - - @Override - protected void onPostExecute(String result) { - Toast.makeText(context, result, Toast.LENGTH_LONG).show(); - } -} -``` - -To make the actual call, invoke this `EndpointsAsyncTask` from one of your Android activities. For example, to execute it from `MainActivity` class, add the following code snippet to `MainActivity.onCreate` method: -```java -new EndpointsAsyncTask().execute(new Pair(this, "Manfred")); -``` - -## 2.1. Testing your app in an emulator - -If you have granted the internet access permission to your `AndroidManifest.xml` file, added compile dependencies to Android app's `build.gradle` file, and added an `EndpointsAsyncTask` invokation to one of your Android app activities as per steps above, you should be all set to test your backend locally! - -First, launch your backend locally as described in section 1.1. and ensure that you can access it via [http://localhost:8080](http://localhost:8080). Then, change the run configuration back to your Android app and run the Android emulator. - -If everything goes well, you should see the following toast in your app: - -!["HelloWorld" backend connected to Android emulator](/doc/img/emulator-endpoints.png) - -## 2.1.1. Testing device registration on a physical device - -Testing on a physical device with a local development server requires minor changes to your configuration. - -1. You must make your development server accessible to the network by setting it to listen to external connections. You can do this by editing the build.gradle for the backend project and setting the httpAddress. - ```gradle - appengine { - .... - httpAddress = "0.0.0.0" - .... - } - ``` - -1. You must also change the endpoint root url to point to your computer's ip address when creating the endpoint . - ```java - Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(), - new AndroidJsonFactory(), null) - .setRootUrl("http://:8080/_ah/api/") - .... - ``` - -## 2.2. Deploying the backend live to App Engine - -If your backend is working locally, you can deploy it to Google App Engine. - -1. Stop the backend, if it is running locally, by selecting -**Run** > **Stop**. - -2. Run **Build** > **Deploy Module to App Engine**. - -![Deploy module to App Engine](/doc/img/deploy-addacct.png) - -3. In the **Deploy to App Engine** dialog, select your module. From the **Deploy To:** dropdown list, choose "Click here to create a new Google Developers Console project." This will open [Google Developers Console](https://console.developers.google.com) - - + If you are running this task for the first time, you will be prompted to -sign-in with your Google Account. Choose an account and sign in.
- -4. Create a new project and switch back to the **Deploy to App Engine** dialog in Android Studio. - + You may also need to initialize the application in App Engine before being able to deploy a new project. To do so, go to the [Google Cloud Console](https://console.cloud.google.com/appengine), and select the region in the follow-up prompt and your application should initialize. Alternatively you can initialize App Engine for your project from the command line using `gcloud app create`. - -5. This would probably be a good time to update your `src/main/webapp/WEB-INF/appengine-web.xml` file's `` property and replace `myApplicationId` with the ID of the project that you just created. This will be important if you try to deploy from the command line. - -6. Click the Refresh button ![Deploy module to App Engine](/doc/img/refresh.png) in the bottom right corner of the **Deploy To:** dropdown list and then select the project you just created. - -7. Click **Deploy**. You can monitor the status of your deployment in the Android Studio console. - -## 2.3. Testing against a deployed backend - -Once you have deployed your backend to App Engine, you can connect your Android app to it by modifying `EndpointsAsyncTask` class defined in section 2 above. In particular, replace the lines -```java -MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) - .setRootUrl("http://10.0.2.2:8080/_ah/api/") // 10.0.2.2 is localhost's IP address in Android emulator - .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { - @Override - public void initialize(AbstractGoogleClientRequest abstractGoogleClientRequest) throws IOException { - abstractGoogleClientRequest.setDisableGZipContent(true); - } - }); -``` -with these two lines -```java -MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) - .setRootUrl("https://android-app-backend.appspot.com/_ah/api/"); -``` -where `android-app-backend` corresponds to your own Project ID created in section 2.2. - -At this point you should be all set to run your Android app in an emulator or on the physical device, and successfully communicate with your new App Engine backend! +Please see https://cloud.google.com/tools/android-studio/docs/ for more. diff --git a/HelloEndpoints/globals.xml.ftl b/HelloEndpoints/globals.xml.ftl deleted file mode 100644 index 57e5e0f..0000000 --- a/HelloEndpoints/globals.xml.ftl +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/HelloEndpoints/recipe.xml.ftl b/HelloEndpoints/recipe.xml.ftl deleted file mode 100644 index 8dd84e9..0000000 --- a/HelloEndpoints/recipe.xml.ftl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/HelloEndpoints/root/build.gradle.ftl b/HelloEndpoints/root/build.gradle.ftl deleted file mode 100644 index c296de1..0000000 --- a/HelloEndpoints/root/build.gradle.ftl +++ /dev/null @@ -1,40 +0,0 @@ -// If you would like more information on the gradle-appengine-plugin please refer to the github page -// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.google.appengine:gradle-appengine-plugin:${appEngineVersion}' - } -} - -repositories { - jcenter(); -} - -apply plugin: 'java' -apply plugin: 'war' -apply plugin: 'appengine' - -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 - -dependencies { - appengineSdk 'com.google.appengine:appengine-java-sdk:${appEngineVersion}' - compile 'com.google.appengine:appengine-endpoints:${appEngineVersion}' - compile 'com.google.appengine:appengine-endpoints-deps:${appEngineVersion}' - compile 'javax.servlet:servlet-api:2.5' -} - -appengine { - downloadSdk = true - appcfg { - oauth2 = true - } - endpoints { - getClientLibsOnBuild = true - getDiscoveryDocsOnBuild = true - } -} diff --git a/HelloEndpoints/root/settings.gradle.ftl b/HelloEndpoints/root/settings.gradle.ftl deleted file mode 100644 index 08ccf84..0000000 --- a/HelloEndpoints/root/settings.gradle.ftl +++ /dev/null @@ -1 +0,0 @@ -include ':${moduleName}' \ No newline at end of file diff --git a/HelloEndpoints/root/src/main/MyBean.java.ftl b/HelloEndpoints/root/src/main/MyBean.java.ftl deleted file mode 100644 index b183e07..0000000 --- a/HelloEndpoints/root/src/main/MyBean.java.ftl +++ /dev/null @@ -1,15 +0,0 @@ -package ${packageName}; - -/** The object model for the data we are sending through endpoints */ -public class MyBean { - - private String myData; - - public String getData() { - return myData; - } - - public void setData(String data) { - myData = data; - } -} \ No newline at end of file diff --git a/HelloEndpoints/root/src/main/MyEndpoint.java.ftl b/HelloEndpoints/root/src/main/MyEndpoint.java.ftl deleted file mode 100644 index 69ae20c..0000000 --- a/HelloEndpoints/root/src/main/MyEndpoint.java.ftl +++ /dev/null @@ -1,36 +0,0 @@ -/* - For step-by-step instructions on connecting your Android application to this backend module, - see "App Engine Java Endpoints Module" template documentation at - https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints -*/ - -package ${packageName}; - -import com.google.api.server.spi.config.Api; -import com.google.api.server.spi.config.ApiMethod; -import com.google.api.server.spi.config.ApiNamespace; - -import javax.inject.Named; - -/** An endpoint class we are exposing */ -@Api( - name = "myApi", - version = "v1", - namespace = @ApiNamespace( - ownerDomain = "${endpointOwnerDomain}", - ownerName = "${endpointOwnerDomain}", - packagePath="${endpointPackagePath}" - ) -) -public class MyEndpoint { - - /** A simple endpoint method that takes a name and says Hi back */ - @ApiMethod(name = "sayHi") - public MyBean sayHi(@Named("name") String name) { - MyBean response = new MyBean(); - response.setData("Hi, " + name); - - return response; - } - -} diff --git a/HelloEndpoints/root/src/webapp/appengine-web.xml.ftl b/HelloEndpoints/root/src/webapp/appengine-web.xml.ftl deleted file mode 100644 index 79b09f3..0000000 --- a/HelloEndpoints/root/src/webapp/appengine-web.xml.ftl +++ /dev/null @@ -1,10 +0,0 @@ - - - ${appId} - 1 - true - - - - - \ No newline at end of file diff --git a/HelloEndpoints/root/src/webapp/index.html.ftl b/HelloEndpoints/root/src/webapp/index.html.ftl deleted file mode 100644 index 6116784..0000000 --- a/HelloEndpoints/root/src/webapp/index.html.ftl +++ /dev/null @@ -1,115 +0,0 @@ - - - - Hello, Endpoints! - - - - - - - - -
- -
- - -
-
-
-

Hello, Endpoints!

-

Enter your name and press the button below to call your Google Cloud Endpoints API.

-
-
- - - - -
-
-
-

If you need step-by-step instructions for connecting your Android application to this backend module, see "App Engine Java Endpoints Module" template documentation.

-

- For more information about Google App Engine for Java, check out the App Engine documentation.
- To learn more about Google Cloud Endpoints, see Cloud Endpoints documentation.
- If you'd like to access your generated Google Cloud Endpoints APIs directly, see the Cloud Endpoints API Explorer. -

-
-
-
-
- - - - - - - diff --git a/HelloEndpoints/root/src/webapp/logging.properties.ftl b/HelloEndpoints/root/src/webapp/logging.properties.ftl deleted file mode 100644 index 0c2ea51..0000000 --- a/HelloEndpoints/root/src/webapp/logging.properties.ftl +++ /dev/null @@ -1,13 +0,0 @@ -# A default java.util.logging configuration. -# (All App Engine logging is through java.util.logging by default). -# -# To use this configuration, copy it into your application's WEB-INF -# folder and add the following to your appengine-web.xml: -# -# -# -# -# - -# Set the default logging level for all loggers to WARNING -.level = WARNING diff --git a/HelloEndpoints/root/src/webapp/web.xml.ftl b/HelloEndpoints/root/src/webapp/web.xml.ftl deleted file mode 100644 index dcb4fc8..0000000 --- a/HelloEndpoints/root/src/webapp/web.xml.ftl +++ /dev/null @@ -1,19 +0,0 @@ - - - - SystemServiceServlet - com.google.api.server.spi.SystemServiceServlet - - services - ${packageName}.MyEndpoint - - - - SystemServiceServlet - /_ah/spi/* - - - - index.html - - \ No newline at end of file diff --git a/HelloEndpoints/template.xml b/HelloEndpoints/template.xml deleted file mode 100644 index 405496e..0000000 --- a/HelloEndpoints/template.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/HelloWorld/README.md b/HelloWorld/README.md index 00bd71d..9b1bc4e 100644 --- a/HelloWorld/README.md +++ b/HelloWorld/README.md @@ -1,175 +1,8 @@ "App Engine Java Servlet Module" Template =========================================== -This Java servlet template is a simplest example of an App Engine backend. It contains the smallest amount of boilerplate code, which makes it perfect for setting up the backend development environment in Android Studio. +This repository has been deprecated. -If you need more abstractions/protections that Endpoints provide (like automated object marshalling/unmarshalling, OAuth 2.0) or push notification support have a look at [App Engine Java Endpoints Module](/HelloEndpoints) and [App Engine Backend with Google Cloud Messaging](/GcmEndpoints) templates. +Starting in Android Studio 3.0, creation of App Engine backends has been removed. -# 1. Adding a backend in Android Studio - -To add the backend to your existing Android app from this backend template, open Android Studio ([installation instructions](https://developer.android.com/sdk/installing/studio.html)) and navigate to "File → New Module..." or right-click on your project and choose "New → Module". - -![New → Module](/doc/img/add-app-engine-backend-menu-scaled.png) - -In the "New Module" wizard that appears, choose "Google Cloud Module": - -![Add App Engine Backend Choose Module](/doc/img/choose_module.png) - -Then choose "App Engine Java Servlet Module". - -![App Engine Java Servlet Module](/doc/img/servlet2.png) - -Enter the module/package names for your new backend, and choose the "client" module in your project which contains your Android app. The client module will be set up to call your newly generated backend. Module name which you've entered above (marked with red **1**) will be used in your Android Studio project. Package name (marked with red **2**) will be used for all classes imported from this template, as shown in the image below. - -![Added "HelloWorld" backend. Red numbers 1 and 2 indicate that the module name and the package name came from "New App Engine Module" dialog](/doc/img/added-backend-helloworld.png) - -## 1.1. Debugging the backend locally - -As soon as the backend module is added to your project and Gradle sync finishes, a new run configuration with your backend's module name should be created: - -![Created run configuration](/doc/img/run-configuration.png) - -Rebuild your project (via "Build → Rebuild Project") and launch this run configuration. It will invoke `appengineRun` task in [Gradle plug-in for App Engine](https://github.com/GoogleCloudPlatform/gradle-appengine-plugin), which in turn will start the local App Engine [Java development server](https://developers.google.com/appengine/docs/java/tools/devserver). - -To ensure that your backend started successfully, navigate to [http://localhost:8080](http://localhost:8080). If everything went well, you should see the following page: - -!["HelloWorld" backend running in local Java development server](/doc/img/devappserver-helloworld.png) - -# 2. Connecting your Android app to the backend - -When you created a backend module, your client module has been set up to access internet. In particular, the following permission has been added into your `AndroidManifest.xml` file: - -```xml - -``` - -To call this backend from your Android app, you simply need to make an HTTP request. The following code snippet illustrates how to create an [AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html) which makes the HTTP request to the backend and prints the incoming result string to a [toast](http://developer.android.com/guide/topics/ui/notifiers/toasts.html) in a given context: - -```java -class ServletPostAsyncTask extends AsyncTask, Void, String> { - private Context context; - - @Override - protected String doInBackground(Pair... params) { - context = params[0].first; - String name = params[0].second; - - try { - // Set up the request - URL url = new URL("http://10.0.2.2:8080/hello"); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("POST"); - connection.setDoInput(true); - connection.setDoOutput(true); - - // Build name data request params - Map nameValuePairs = new HashMap<>(); - nameValuePairs.put("name", name); - String postParams = buildPostDataString(nameValuePairs); - - // Execute HTTP Post - OutputStream outputStream = connection.getOutputStream(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); - writer.write(postParams); - writer.flush(); - writer.close(); - outputStream.close(); - connection.connect(); - - // Read response - int responseCode = connection.getResponseCode(); - StringBuilder response = new StringBuilder(); - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String line; - while ((line = reader.readLine()) != null) { - response.append(line); - } - reader.close(); - - if (responseCode == HttpsURLConnection.HTTP_OK) { - return response.toString(); - } - return "Error: " + responseCode + " " + connection.getResponseMessage(); - - } catch (IOException e) { - return e.getMessage(); - } - } - - private String buildPostDataString(Map params) throws UnsupportedEncodingException { - StringBuilder result = new StringBuilder(); - boolean first = true; - for (Map.Entry entry : params.entrySet()) { - if (first) { - first = false; - } else { - result.append("&"); - } - - result.append(URLEncoder.encode(entry.getKey(), "UTF-8")); - result.append("="); - result.append(URLEncoder.encode(entry.getValue(), "UTF-8")); - } - - return result.toString(); - } - - @Override - protected void onPostExecute(String result) { - Toast.makeText(context, result, Toast.LENGTH_LONG).show(); - } -} -``` - -Finally, you need to invoke this AsyncTask from one of your Android activities. For example, to execute it from `MainActivity` class, add the following code snippet to `MainActivity.onCreate` method: -```java -new ServletPostAsyncTask().execute(new Pair(this, "Manfred")); -``` - -## 2.1. Testing your app in an emulator - -If you have created a `ServletPostAsyncTask` and added its invokation to one of your Android app activities as per steps above, you should be all set to test your backend locally! - -First, launch your backend locally as described in section 1.1. and ensure that you can access it via [http://localhost:8080](http://localhost:8080). Then, change the run configuration back to your Android app and run the Android emulator. - -If everything goes well, you should see the following toast in your app: - -!["HelloWorld" backend connected to Android emulator](/doc/img/emulator-helloworld.png) - -## 2.2. Deploying the backend live to App Engine - -If your backend is working locally, you can deploy it to Google App Engine. - -1. Stop the backend, if it is running locally, by selecting -**Run** > **Stop**. - -2. Run **Build** > **Deploy Module to App Engine**. - -![Deploy module to App Engine](/doc/img/deploy-addacct.png) - -3. In the **Deploy to App Engine** dialog, select your module. From the **Deploy To:** dropdown list, choose "Click here to create a new Google Developers Console project." This will open [Google Developers Console](https://console.developers.google.com) - - + If you are running this task for the first time, you will be prompted to -sign-in with your Google Account. Choose an account and sign in.
- -4. Create a new project and switch back to the **Deploy to App Engine** dialog in Android Studio. - -5. This would probably be a good time to update your `src/main/webapp/WEB-INF/appengine-web.xml` file's `` property and replace `myApplicationId` with the ID of the project that you just created. This will be important if you try to deploy from the command line. - -6. Click the Refresh button ![Deploy module to App Engine](/doc/img/refresh.png) in the bottom right corner of the **Deploy To:** dropdown list and then select the project you just created. - -7. Click **Deploy**. You can monitor the status of your deployment in the Android Studio console. - -## 2.3. Testing against a deployed backend - -Once you have deployed your backend to App Engine, you can connect your Android app to it by modifying `ServletPostAsyncTask` class defined in section 2 above. In particular, replace the line -```java -HttpPost httpPost = new HttpPost("http://10.0.2.2:8080/hello"); -``` -with -```java -HttpPost httpPost = new HttpPost("http://android-app-backend.appspot.com/hello"); -``` -where `android-app-backend` corresponds to your own Project ID created in section 2.2. - -At this point you should be all set to run your Android app in an emulator or on the physical device, and successfully communicate with your new App Engine backend! +Please see https://cloud.google.com/tools/android-studio/docs/ for more. diff --git a/HelloWorld/globals.xml.ftl b/HelloWorld/globals.xml.ftl deleted file mode 100644 index 57e5e0f..0000000 --- a/HelloWorld/globals.xml.ftl +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/HelloWorld/recipe.xml.ftl b/HelloWorld/recipe.xml.ftl deleted file mode 100644 index d83f379..0000000 --- a/HelloWorld/recipe.xml.ftl +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/HelloWorld/root/build.gradle.ftl b/HelloWorld/root/build.gradle.ftl deleted file mode 100644 index 3ff6f74..0000000 --- a/HelloWorld/root/build.gradle.ftl +++ /dev/null @@ -1,34 +0,0 @@ -// If you would like more information on the gradle-appengine-plugin please refer to the github page -// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.google.appengine:gradle-appengine-plugin:${appEngineVersion}' - } -} - -repositories { - jcenter(); -} - -apply plugin: 'java' -apply plugin: 'war' -apply plugin: 'appengine' - -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 - -dependencies { - appengineSdk 'com.google.appengine:appengine-java-sdk:${appEngineVersion}' - compile 'javax.servlet:servlet-api:2.5' -} - -appengine { - downloadSdk = true - appcfg { - oauth2 = true - } -} diff --git a/HelloWorld/root/settings.gradle.ftl b/HelloWorld/root/settings.gradle.ftl deleted file mode 100644 index 08ccf84..0000000 --- a/HelloWorld/root/settings.gradle.ftl +++ /dev/null @@ -1 +0,0 @@ -include ':${moduleName}' \ No newline at end of file diff --git a/HelloWorld/root/src/main/MyServlet.java.ftl b/HelloWorld/root/src/main/MyServlet.java.ftl deleted file mode 100644 index a3ea61a..0000000 --- a/HelloWorld/root/src/main/MyServlet.java.ftl +++ /dev/null @@ -1,30 +0,0 @@ -/* - For step-by-step instructions on connecting your Android application to this backend module, - see "App Engine Java Servlet Module" template documentation at - https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld -*/ - -package ${packageName}; - -import java.io.IOException; -import javax.servlet.http.*; - -public class MyServlet extends HttpServlet { - @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - resp.setContentType("text/plain"); - resp.getWriter().println("Please use the form to POST to this url"); - } - - @Override - public void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - String name = req.getParameter("name"); - resp.setContentType("text/plain"); - if(name == null) { - resp.getWriter().println("Please enter a name"); - } - resp.getWriter().println("Hello " + name); - } -} diff --git a/HelloWorld/root/src/webapp/appengine-web.xml.ftl b/HelloWorld/root/src/webapp/appengine-web.xml.ftl deleted file mode 100644 index 79b09f3..0000000 --- a/HelloWorld/root/src/webapp/appengine-web.xml.ftl +++ /dev/null @@ -1,10 +0,0 @@ - - - ${appId} - 1 - true - - - - - \ No newline at end of file diff --git a/HelloWorld/root/src/webapp/index.html.ftl b/HelloWorld/root/src/webapp/index.html.ftl deleted file mode 100644 index a08cfdb..0000000 --- a/HelloWorld/root/src/webapp/index.html.ftl +++ /dev/null @@ -1,48 +0,0 @@ - - - - Hello, App Engine! - - - - - - - -
-
-
-
-

Hello, App Engine!

-

Enter your name and press the button below to call MyServlet.

- -
-
- - - - -
-
-
-

For more information about Google App Engine for Java, check out the App Engine documentation.

-

If you need step-by-step instructions for connecting your Android application to this backend module, see "App Engine Java Servlet Module" template documentation.

-
-
-
-
- - - diff --git a/HelloWorld/root/src/webapp/logging.properties.ftl b/HelloWorld/root/src/webapp/logging.properties.ftl deleted file mode 100644 index 0c2ea51..0000000 --- a/HelloWorld/root/src/webapp/logging.properties.ftl +++ /dev/null @@ -1,13 +0,0 @@ -# A default java.util.logging configuration. -# (All App Engine logging is through java.util.logging by default). -# -# To use this configuration, copy it into your application's WEB-INF -# folder and add the following to your appengine-web.xml: -# -# -# -# -# - -# Set the default logging level for all loggers to WARNING -.level = WARNING diff --git a/HelloWorld/root/src/webapp/web.xml.ftl b/HelloWorld/root/src/webapp/web.xml.ftl deleted file mode 100644 index b69573f..0000000 --- a/HelloWorld/root/src/webapp/web.xml.ftl +++ /dev/null @@ -1,14 +0,0 @@ - - - - MyServlet - ${packageName}.MyServlet - - - MyServlet - /hello - - - index.html - - \ No newline at end of file diff --git a/HelloWorld/template.xml b/HelloWorld/template.xml deleted file mode 100644 index 1a93a13..0000000 --- a/HelloWorld/template.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 792467a..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,4 +0,0 @@ -LICENSE - -The included templates are freely usable for any purpose. -They are also AS-IS, and come with *no* warranty of any sort. diff --git a/README.md b/README.md index c30bfdb..fe6164c 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,8 @@ App Engine backend templates in Android Studio ========================== -You can use [Google App Engine](https://developers.google.com/appengine) backend templates hosted in this repository to add a backend to your existing (or new) Android application from [Android Studio IDE](http://developer.android.com/sdk/installing/studio.html). +This repository has been deprecated. -All of these backends are designed to be hosted on App Engine (which provides autoscaling and high-availability out-of-the-box), and can be used under App Engine's [free resource quotas](https://developers.google.com/appengine/docs/quotas). +Starting in Android Studio 3.0, creation of App Engine backends has been removed. -# 1. Usage - -This repository contains three backend template types, which can be added into your Android app by navigating to "File → New Module..." menu, or by right-clicking on your project and choosing "New → Module". - -![Tools → Google Cloud Tools → Add App Engine Backend](/doc/img/add-app-engine-backend-menu-scaled.png) - -In the "New Module" wizard that appears, choose "Google Cloud Module": - -![Add App Engine Backend Choose Module](/doc/img/choose_module.png) - -Then choose one out of the following template types: - -![Add App Engine Backend Choose Template](/doc/img/all.png) - -1. [App Engine Java Servlet Module](/HelloWorld) [[HelloWorld](/HelloWorld)]: a simple App Engine Java backend servlet with minimal boilerplate code, -2. [App Engine Java Endpoints Module](/HelloEndpoints) [[HelloEndpoints](/HelloEndpoints)]: a backend which leverages [Google Cloud Endpoints](https://developers.google.com/appengine/docs/java/endpoints) for automated object marshalling/unmarshalling, generation of strongly-typed Java client libraries and so on, -3. [App Engine Backend with Google Cloud Messaging](/GcmEndpoints) [[GcmEndpoints](/GcmEndpoints)]: a mobile backend with Google Cloud Endpoints and [Google Cloud Messaging](http://developer.android.com/google/gcm) integration, which supports more advanced features like push notifications. - -For detailed instructions on how to use each of these templates to add a backend to your Android app see the individual template directories ([HelloWorld](/HelloWorld), [HelloEndpoints](/HelloEndpoints) or [GcmEndpoints](/GcmEndpoints)). - -# 2. Prerequisites - -App Engine requires Java 7 SDK. You can check which SDK your project is using by navigating to "File → Project Structure...". - -![JDK settings in File → Project Structure...](/doc/img/jdk-settings.png) - -These templates use [FreeMarker](http://freemarker.org) (but it is not required if you are adding these templates via Android Studio). - -# 3. Troubleshooting - -If you have any problems adding these backends to your Android applications, contact us on [Android Developers G+ community](https://plus.google.com/+AndroidDevelopers) or write us a question on StackOverflow using [google-app-engine](http://stackoverflow.com/questions/tagged/google-app-engine) or [google-cloud-endpoints](http://stackoverflow.com/questions/tagged/google-cloud-endpoints) tags. - -## 3.1. Useful links - -Click on the following links to get more information about: -* [Google App Engine](https://developers.google.com/appengine/), -* [Google Cloud Endpoints](https://developers.google.com/appengine/docs/java/endpoints/), -* [Google Cloud Messaging](http://developer.android.com/google/gcm/index.html), -* [Android Studio](http://developer.android.com/sdk/installing/studio.html). +Please see https://cloud.google.com/tools/android-studio/docs/ for more. diff --git a/doc/img/add-app-engine-backend-dialog-step-2.png b/doc/img/add-app-engine-backend-dialog-step-2.png deleted file mode 100644 index c9339c7..0000000 Binary files a/doc/img/add-app-engine-backend-dialog-step-2.png and /dev/null differ diff --git a/doc/img/add-app-engine-backend-dialog.png b/doc/img/add-app-engine-backend-dialog.png deleted file mode 100644 index 13310d3..0000000 Binary files a/doc/img/add-app-engine-backend-dialog.png and /dev/null differ diff --git a/doc/img/add-app-engine-backend-menu-endpoints.png b/doc/img/add-app-engine-backend-menu-endpoints.png deleted file mode 100644 index 0668006..0000000 Binary files a/doc/img/add-app-engine-backend-menu-endpoints.png and /dev/null differ diff --git a/doc/img/add-app-engine-backend-menu-gcm.png b/doc/img/add-app-engine-backend-menu-gcm.png deleted file mode 100644 index ac962b3..0000000 Binary files a/doc/img/add-app-engine-backend-menu-gcm.png and /dev/null differ diff --git a/doc/img/add-app-engine-backend-menu-helloworld.png b/doc/img/add-app-engine-backend-menu-helloworld.png deleted file mode 100644 index f358a4c..0000000 Binary files a/doc/img/add-app-engine-backend-menu-helloworld.png and /dev/null differ diff --git a/doc/img/add-app-engine-backend-menu-scaled.png b/doc/img/add-app-engine-backend-menu-scaled.png deleted file mode 100644 index a02d022..0000000 Binary files a/doc/img/add-app-engine-backend-menu-scaled.png and /dev/null differ diff --git a/doc/img/add-app-engine-backend-menu.png b/doc/img/add-app-engine-backend-menu.png deleted file mode 100644 index 82f4310..0000000 Binary files a/doc/img/add-app-engine-backend-menu.png and /dev/null differ diff --git a/doc/img/added-backend-endpoints.png b/doc/img/added-backend-endpoints.png deleted file mode 100644 index 0af585e..0000000 Binary files a/doc/img/added-backend-endpoints.png and /dev/null differ diff --git a/doc/img/added-backend-gcm.png b/doc/img/added-backend-gcm.png deleted file mode 100644 index f435201..0000000 Binary files a/doc/img/added-backend-gcm.png and /dev/null differ diff --git a/doc/img/added-backend-helloworld.png b/doc/img/added-backend-helloworld.png deleted file mode 100644 index a29b5e4..0000000 Binary files a/doc/img/added-backend-helloworld.png and /dev/null differ diff --git a/doc/img/all.png b/doc/img/all.png deleted file mode 100755 index b4f7854..0000000 Binary files a/doc/img/all.png and /dev/null differ diff --git a/doc/img/app-engine-permissions.png b/doc/img/app-engine-permissions.png deleted file mode 100644 index 7ba33ea..0000000 Binary files a/doc/img/app-engine-permissions.png and /dev/null differ diff --git a/doc/img/avd-manager-google-api-image.png b/doc/img/avd-manager-google-api-image.png deleted file mode 100644 index fd249cd..0000000 Binary files a/doc/img/avd-manager-google-api-image.png and /dev/null differ diff --git a/doc/img/backend-message.png b/doc/img/backend-message.png deleted file mode 100644 index b1ce5bf..0000000 Binary files a/doc/img/backend-message.png and /dev/null differ diff --git a/doc/img/backend-notification.png b/doc/img/backend-notification.png deleted file mode 100644 index 89f448c..0000000 Binary files a/doc/img/backend-notification.png and /dev/null differ diff --git a/doc/img/choose_module.png b/doc/img/choose_module.png deleted file mode 100644 index eeec731..0000000 Binary files a/doc/img/choose_module.png and /dev/null differ diff --git a/doc/img/deploy-addacct.png b/doc/img/deploy-addacct.png deleted file mode 100644 index 812b2cc..0000000 Binary files a/doc/img/deploy-addacct.png and /dev/null differ diff --git a/doc/img/deploy-helloworld.png b/doc/img/deploy-helloworld.png deleted file mode 100644 index c87a2c4..0000000 Binary files a/doc/img/deploy-helloworld.png and /dev/null differ diff --git a/doc/img/dev-console-gcm-register.png b/doc/img/dev-console-gcm-register.png deleted file mode 100644 index 6140fc2..0000000 Binary files a/doc/img/dev-console-gcm-register.png and /dev/null differ diff --git a/doc/img/dev-console-key-view.png b/doc/img/dev-console-key-view.png deleted file mode 100644 index e6350c0..0000000 Binary files a/doc/img/dev-console-key-view.png and /dev/null differ diff --git a/doc/img/dev-console-project-overview.png b/doc/img/dev-console-project-overview.png deleted file mode 100644 index 5213678..0000000 Binary files a/doc/img/dev-console-project-overview.png and /dev/null differ diff --git a/doc/img/dev-console-server-key.png b/doc/img/dev-console-server-key.png deleted file mode 100644 index c8b3d7f..0000000 Binary files a/doc/img/dev-console-server-key.png and /dev/null differ diff --git a/doc/img/devappserver-endpoints.png b/doc/img/devappserver-endpoints.png deleted file mode 100644 index 984b60b..0000000 Binary files a/doc/img/devappserver-endpoints.png and /dev/null differ diff --git a/doc/img/devappserver-gcm.png b/doc/img/devappserver-gcm.png deleted file mode 100644 index 2541b58..0000000 Binary files a/doc/img/devappserver-gcm.png and /dev/null differ diff --git a/doc/img/devappserver-helloworld.png b/doc/img/devappserver-helloworld.png deleted file mode 100644 index a76cf52..0000000 Binary files a/doc/img/devappserver-helloworld.png and /dev/null differ diff --git a/doc/img/developer-console-api.png b/doc/img/developer-console-api.png deleted file mode 100644 index 320788c..0000000 Binary files a/doc/img/developer-console-api.png and /dev/null differ diff --git a/doc/img/developer-console-key.png b/doc/img/developer-console-key.png deleted file mode 100644 index d691b52..0000000 Binary files a/doc/img/developer-console-key.png and /dev/null differ diff --git a/doc/img/developer-console-project-id.png b/doc/img/developer-console-project-id.png deleted file mode 100644 index c6bdaac..0000000 Binary files a/doc/img/developer-console-project-id.png and /dev/null differ diff --git a/doc/img/developer-console-project.png b/doc/img/developer-console-project.png deleted file mode 100644 index 4525c90..0000000 Binary files a/doc/img/developer-console-project.png and /dev/null differ diff --git a/doc/img/emulator-avd.png b/doc/img/emulator-avd.png deleted file mode 100644 index f5b805d..0000000 Binary files a/doc/img/emulator-avd.png and /dev/null differ diff --git a/doc/img/emulator-endpoints.png b/doc/img/emulator-endpoints.png deleted file mode 100644 index ce97dc5..0000000 Binary files a/doc/img/emulator-endpoints.png and /dev/null differ diff --git a/doc/img/emulator-gcm.png b/doc/img/emulator-gcm.png deleted file mode 100644 index 3498f0b..0000000 Binary files a/doc/img/emulator-gcm.png and /dev/null differ diff --git a/doc/img/emulator-helloworld.png b/doc/img/emulator-helloworld.png deleted file mode 100644 index 83b367d..0000000 Binary files a/doc/img/emulator-helloworld.png and /dev/null differ diff --git a/doc/img/endpoints2.png b/doc/img/endpoints2.png deleted file mode 100644 index ff9763d..0000000 Binary files a/doc/img/endpoints2.png and /dev/null differ diff --git a/doc/img/gcm-api.png b/doc/img/gcm-api.png deleted file mode 100644 index 7e0df0c..0000000 Binary files a/doc/img/gcm-api.png and /dev/null differ diff --git a/doc/img/gcm2.png b/doc/img/gcm2.png deleted file mode 100644 index f590bf9..0000000 Binary files a/doc/img/gcm2.png and /dev/null differ diff --git a/doc/img/install-client-libraries.png b/doc/img/install-client-libraries.png deleted file mode 100644 index 8be4637..0000000 Binary files a/doc/img/install-client-libraries.png and /dev/null differ diff --git a/doc/img/jdk-settings.png b/doc/img/jdk-settings.png deleted file mode 100644 index d7ca9c0..0000000 Binary files a/doc/img/jdk-settings.png and /dev/null differ diff --git a/doc/img/new-developer-console-project-flow.png b/doc/img/new-developer-console-project-flow.png deleted file mode 100644 index 0003bf6..0000000 Binary files a/doc/img/new-developer-console-project-flow.png and /dev/null differ diff --git a/doc/img/new-developer-console-project.png b/doc/img/new-developer-console-project.png deleted file mode 100644 index 936ea8e..0000000 Binary files a/doc/img/new-developer-console-project.png and /dev/null differ diff --git a/doc/img/refresh.png b/doc/img/refresh.png deleted file mode 100644 index 8f05bae..0000000 Binary files a/doc/img/refresh.png and /dev/null differ diff --git a/doc/img/run-configuration.png b/doc/img/run-configuration.png deleted file mode 100644 index 8fe83d2..0000000 Binary files a/doc/img/run-configuration.png and /dev/null differ diff --git a/doc/img/servlet2.png b/doc/img/servlet2.png deleted file mode 100644 index 0ae0ce2..0000000 Binary files a/doc/img/servlet2.png and /dev/null differ diff --git a/doc/img/stop-devappserver-helloworld.png b/doc/img/stop-devappserver-helloworld.png deleted file mode 100644 index ea5d09b..0000000 Binary files a/doc/img/stop-devappserver-helloworld.png and /dev/null differ diff --git a/doc/img/update-helloworld-1.png b/doc/img/update-helloworld-1.png deleted file mode 100644 index 6409506..0000000 Binary files a/doc/img/update-helloworld-1.png and /dev/null differ diff --git a/doc/img/update-helloworld-2.png b/doc/img/update-helloworld-2.png deleted file mode 100644 index a8b7b24..0000000 Binary files a/doc/img/update-helloworld-2.png and /dev/null differ