Endpoint.Builder missing for generated cloud endpoint

荒凉一梦 提交于 2019-12-03 10:13:36

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.

Note This answer is based on Android Studio, but am sure it's pretty much the same as Eclipse.

I also had this issue but later found the cause.Turns out I was importing the Endpoint class I generated instead of the endpoint Api package. Let me be clear.When you add the endpoint module to your project, you get the MyBean and MyEndpoint classes in the endpoint package. If you take a look at the guide to connecting your client to your backend, the EndpointsAsyncTask class uses:

private static MyApi myApiService = null;

Note how it uses MyApi instead of MyBean Now I was wondering where it got that from but I just have to take a look at my backend libraries:

The library marked 1 is the library first added to your project when you follow the guide previously mentioned. When I added a new class Student and autogenerated the cloud endpoint class, the second library was also added.

Long, boring story short; It is this library you should be importing and not the class.

import com.package-name.backend.studentApi.StudentApi;

and then using:

private static StudentApi myApiService = null;
...
StudentApi.Builder builder = new StudentApi.Builder(...)

instead of:

import com.package-name.backend.StudentEndpoint;
 ...
private static StudentEndpoint myApiService = null;

StudentEndpoint.Builder builder = new StudentEndpoint.Builder(...)

I got the same problem in Android Studio. I generated my Endpoint class from my entity java bean but when creating the AsyncTask, now way to get the Builder.

Actually (if I take a Game java bean like you) the Builder is not depending on the GameEndPoint but on the generated GameApi class.

In other words, I had to add these two imports in the AsyncTask class:

import com.examplepackage.backend.gameApi.GameApi; import com.examplepackage.backend.gameApi.model.Game;

while the Game java bean that you wrote and the generated GameEndpoint are under package com.examplepackage.backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!