Il metodo endpoint assomiglia a questo:metodo endpoint Google continua a tornare "nome non deve essere vuoto" eccezione
@Api(
name = "gameape",
version = "v1",
description = "Game App API",
audiences = { "mynumber.apps.googleusercontent.com" },
clientIds = { "mynumber.apps.googleusercontent.com", Constant.API_EXPLORER_CLIENT_ID },
defaultVersion = AnnotationBoolean.TRUE)
public class GameApp {
private final AccountDao accountDao = new AccountDaoImpl();
@ApiMethod(name = "LoginUser", path = "LoginUser", httpMethod = HttpMethod.POST)
public void LoginUser(LoginData request) {
long phone = request.getPhone();
String deviceId = request.getDeviceId();
String gcmToken = request.getGcmToken();
Account acc = new Account(phone, deviceId, gcmToken);
accountDao.put(acc);
ApiHelper.sendGCM(phone, "welcome to my game app");
}
}
Il frammento da sguardi Android come questo:
@Override
protected Boolean doInBackground(Void... params) {
LoginData request = new LoginData();
request.setUsername(username);
request.setPassword(password);
try {
RegisterUser reg = service.registerUser(request);
reg.execute();
return true;
} catch (Exception e) {
Log.e(LoginActivity.class.getName(),
"Exception received from server at "
+ service.getRootUrl(), e);
}
return false;
}
Calling reg.execute()
mantiene gettando il eccezione:
java.lang.IllegalArgumentException: the name must not be empty: null
dalla console del server, non sembra neanche l ike viene colpito il server. Anche quando provo a eseguire il server in modalità di debug, non viene raggiunto il punto di interruzione (metodo interno prima riga).
EDIT: aggiunta di analisi dello stack:
04-03 13:38:42.688: I/com.me.gameapp.LoginActivity$UserLoginTask(11255): Enter doInBackground
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): Exception received from server at https://1.myapp.appspot.com/_ah/api/
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): java.lang.IllegalArgumentException: the name must not be empty: null
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at android.os.Parcel.readException(Parcel.java:1251)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at android.os.Parcel.readException(Parcel.java:1235)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.android.gms.internal.x$a$a.a(Unknown Source)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:192)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:217)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:836)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:412)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:345)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:463)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.me.gameapp.LoginActivity$UserLoginTask.doInBackground(LoginActivity.java:262)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at com.me.gameapp.LoginActivity$UserLoginTask.doInBackground(LoginActivity.java:1)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
04-03 13:38:42.786: E/com.me.gameapp.LoginActivity(11255): at java.lang.Thread.run(Thread.java:1096)
04-03 13:38:42.786: I/com.me.gameapp.LoginActivity$UserLoginTask(11255): Leave doInBackground with false
Nella linea Exception received from server at https://1.myapp.appspot.com/_ah/api/
, Sono in esecuzione tutto su localhost. Forse https://1.myapp.appspot.com/_ah/api/
è sbagliato. Il mio codice è molto vicino al modello, quindi, quindi non sono sicuro che sia un cambiamento che ho commesso.
Puoi condividere la traccia dello stack completo? Sospetto che l'errore sia nel tuo codice Android. –
@DanHolevoet Ho aggiunto la traccia dello stack. – learner
Inoltre, sono in grado di colpire il server attraverso l'API explorer; ma non attraverso il codice Android. – learner