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)



Code Validation and Quick Fixes for Endpoints Backends

Server-side Endpoints API definitions must conform to a number of syntactic rules. Android Studio knows these and validates your code as you type to help you avoid making mistakes. Android Studio provides Endpoints-specific inspections and quick-fixes.

As-you-type code validation

For example, the default backend type App Engine Java Endpoints Module , contains the following minimal annotated Endpoints API located in your project at <backend-name>/src/main/java/<package-name>/MyEndpoint.java :

    import javax.inject.Named;

    @Api(name = "myApi", version = "v1", 
         namespace = @ApiNamespace(ownerDomain = "<package-name>",
                                   ownerName = "<package-name>",
                                   packagePath=""))
    public class MyEndpoint {

        @ApiMethod(name = "sayHi")
        public MyBean sayHi(@Named("name") String name) {
          MyBean response = new MyBean();
          response.setData("Hi, " + name);

          return response;
        }
    }

In the code, @Named is required for all non-entity type parameters passed to server-side methods. If you forget to add this annotation when modifying sayHi in this code, Android Studio will underline the problematic statement as you type, as shown below:

Add Backend

Quick fixes

In addition, to help you easily fix the problems with Cloud Endpoints, Android Studio will provide quick-fixes for the most common Cloud Endpoints development mistakes. To see these quick-fix suggestions, using the code example above with the missing @Named annotation, press Alt + Enter if you’re running on Linux/Windows or + Enter if you’re running on Mac:

Add Backend

As expected, choosing the first quick-fix ( Add @Named ) will automatically add @Named to the method parameter.

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.