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)



Running, Testing, and Deploying the Backend

You can run and test your backend locally, and deploy the backend using Android Studio.

Running and testing the backend locally

After adding the Endpoints backend template, you should test it locally to make sure your environment is functioning properly. To run the backend template locally:

  1. Click Run > Edit Configurations to open the Run/Debug Configurations form:

    Run backend configuration

    Note that when you add the backend module template to your project and do the Gradle sync as described, a new run configuration is created for the backend; it has the module name you assigned during backend creation.

  2. In the left pane, under App Engine DevAppServer, locate the backend module you just added, select it, and click OK .

  3. Click Build > Rebuild Project and wait for the build to finish.

  4. Select Run > Run <your-backend-module-name> to launch the backend in the local App Engine development server in Android Studio:

    Run backend configuration

  5. Wait for the backend to start up in the development server; when it finishes loading, a message similar to the following is displayed in the console:

        Jun 18, 2014 4:07:30 PM com.google.appengine.tools.development.AbstractModule startup
        INFO: The admin console is running at http://localhost:8080/_ah/admin
        Jun 18, 2014 4:07:30 PM com.google.appengine.tools.development.DevAppServerImpl doStart
        INFO: Dev App Server is now running
    
  6. Navigate to http://localhost:8080 on the machine running your Android Studio project. If everything went well, you should see a page similar to the following:

    "HelloWorld" backend running locally

    (The page shown is for the Endpoints backend. The page for the other templates will be slightly different.)

    Notice the links at the top of the page, especially the link that takes you to to the Google Developer Console, where you can create or configure a Cloud project. (You'll need a cloud project to deploy your backend after your development and testing work is complete.)

At this point, the default backend from the template is successfully running. However, your Android app is not yet connected to the backend: you'll need to add some code to your Android app so it can access the backend, as described in the appropriate template README file:

You'll also need to add whatever customized behavior you want your backend to have.

Testing the Endpoints backends using API Explorer

For backends that have Endpoints, you can test the functioning of the API directly using the built-in Google API Explorer:

  1. Start and run your backend locally as described previously.

  2. Navigate to http://localhost:8080/_ah/api/explorer on the machine running your Android Studio project. If everything went well, you should see a page similar to the following:

  3. Click the API name, for example myApi API , to display the methods available from this API.

  4. Click a method, for example, myApi.sayHi to display the Explorer form for this method:

    SayHi form

  5. Supply a value for the input field if it has one; using the default backend as an example, supply your name in the name field. Click Execute and check the Response for the expected response.

Deploying backends

Before deploying your backend, you need to create a Cloud project for it and add the project ID to your backend, as described in the README for your backend template ( Servlet Module / Endpoints Module / Backend with Google Cloud Messaging ) To deploy your backend to App Engine from Android Studio:

  1. Stop the backend, if it is running locally, by selecting Run > Stop .

  2. Select Tools > Open Terminal .

  3. Enter the command

        ./gradlew backend:appengineUpdate
    
  4. If you are running this task for the first time, you will be prompted to sign-in with your Google Account. After choosing the account and signing-in, give permissions to Google App Engine's appcfg tool and copy-paste the generated key back into the terminal window:

    copy permissions

    Then press Enter to deploy.

Your app is now deployed and ready for clients.

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.