0
votes

Please assist me in figuring out how to create an endpoint from a java class. A lot has changed in android studio, and the ability to:

Tools -> Google Cloud Tools -> Generate Endpoint

Or

Click on the java class and then select Generate Endpoint

Seems to have disappeared with the new android studio? What should I do, or am I missing something I need to do within android studio?

Code:

public class SearchObject {

    private String Location;

    public String getLocation() {
        return Location;
    }

    public void setLocation(String location) {
        Location = location;
    }
}

Even tried to manully create the endpoint but doesn't seem to work, the reponse object is giving an error:

@Api(name = "searchApi",
        version = "v1",
        namespace = @ApiNamespace(ownerDomain = "backend.co.za",
                ownerName = "backend.co.za",
                packagePath=""))
public class SearchAPI {
    @ApiMethod(name = "Search")
    public void sayHi(@Named("location") String location) {
        SearchObject response = new SearchObject();
        response.setData("Hi, " + location); //Problem, cannot resolve method

        return response;
    }

}
2

2 Answers

0
votes

Select File | New Module | Google Cloud Module. Then select "App Engine Java Endpoints Module" as the module type.

0
votes

Found the problem: when I right click on the class SearchObject I could not find the 'Generate google endpoint' option because it "hides" behind my task bar at the bottom of my screen!!

Not sure if it is just a linux (Mint) thing or problem with android studio.

Hope no one else gets stuck for hours with the same issue.