Search code examples
androideclipsegoogle-cloud-platformgoogle-app-enginegoogle-plugin-eclipse

Endpoint.Builder missing for generated cloud endpoint


I'm attempting to follow the example tutorial at https://developers.google.com/eclipse/docs/endpoints-addentities and I'm stuck figuring out how to get the GameEndpoint.Builder class to generate within Eclipse.

After following this and generating the cloud endpoints as described, I have a GameEndpoint class created, but there is no GameEndpoint.Builder class. So obviously I have this error

GameEndpoint.Builder cannot be resolved to a type

I'm stumped at this point. How do I generate the GameEndpoint.Builder class within Eclipse, or what would prevent it?

Code

public class NewGameTask extends AsyncTask<Context, Integer, Long> {
    protected Long doInBackground(Context... contexts) {

        GameEndpoint.Builder endpointBuilder = new GameEndpoint.Builder(
                AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
                new HttpRequestInitializer() {
                    public void initialize(HttpRequest httpRequest) {
                    }
                });
        GameEndpoint endpoint = CloudEndpointUtils.updateBuilder(
                endpointBuilder).build();
        try {
            Game game = new Game();
            game.setStart(Calendar.getInstance());

            Game result = endpoint.insertGame(game);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (long) 0;
    }
}

Solution

  • I figured out my issue after watching this video from Google I/O 2013 which is using Android Studio, but it was the same thing as Eclipse mostly.

    My mistake in following https://developers.google.com/eclipse/docs/endpoints-addentities was that you need to put your entity class into the MyApp-AppEngine project and NOT your MyApp project.

    That was the source of confusion. In case it helps those in the future, here is a short breakdown of what I did.

    • Put the Entity class you want to add to App Engine into your MyApp-AppEngine project.
    • Right click your class and go to Google > Generate Cloud Endpoint Client Library
    • Right click your MyApp-AppEngine project and go to Google > Generate Cloud Enpoint Client Library
    • New references will be made in your MyApp project which you reference in your project for usage.