Sposób końcowy wygląda tak:metoda końcowym Google wciąż powraca „Nazwa nie może być pusta” wyjątek
@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");
}
}
Fragment z Android wygląda następująco:
@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;
}
Wywołanie reg.execute()
utrzymuje rzucanie wyjątek:
java.lang.IllegalArgumentException: the name must not be empty: null
Z konsoli serwera nawet nie wygląda ike serwer jest trafiony. Nawet gdy próbuję uruchomić serwer w trybie debugowania, mój punkt przerwania (metoda pierwszego wiersza w środku) nie zostanie osiągnięty.
EDIT: dodawanie ślad stosu:
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
W linii Exception received from server at https://1.myapp.appspot.com/_ah/api/
, używam wszystko na localhost. Może https://1.myapp.appspot.com/_ah/api/
jest źle. Mój kod jest bardzo zbliżony do szablonu, więc nie jestem pewien, czy to zmiana, którą popełniłem.
Czy możesz udostępnić pełne śledzenie stosu? Podejrzewam, że błąd występuje w Twoim kodzie Android. –
@DanHolevoet Dodałem ślad stosu. – learner
Ponadto, jestem w stanie trafić serwer poprzez api explorer; ale nie przez kod Androida. – learner