[帖子底部的代码]
我正在部署我的google appengine后端数据存储区,以便在Android应用程序中使用。我在我的devserver上使用端点,我正在尝试"存储"标准信息 - 字符串+整数到我的数据存储区。
尝试"存储"该行的一个对象" m_suaMyApi.storeBean(...)",我得到了 " GoogleJsonResponseException:404 Not Found" 错误。
我不知道为什么会抛出这个错误,并且几天来一直在寻找和纠正问题。
到目前为止,我已尝试以下方法解决问题但没有运气:
如此处所述,在我的应用的安全ids部分添加说明,(保存后)我将应用程序还原为开放式开发并重新保存。 Android Mobile Backend Starter fail with 404 not found... some times
我制作了我上传的应用版本"默认"如本问题解决博客文章#3中所述: http://kakoma.ug/code/2014/02/android-dev-tutorial-setting-app-engine-connected-app-hiccups
我已删除并重新部署了我的后端和我的应用
我关闭了我的实例,让它重新启动并重试我的Android应用程序。
经过这些尝试后,我仍然遇到同样的错误。
此时我已经走到了尽头,可以使用一些帮助。
///////////////////////////////
" save"我对端点的对象
public class MyAsyncTask extends AsyncTask<Pair<Context, String>, Void, String> {
private MyApi m_suaMyApi = null;
private Context m_context;
private boolean m_debug = true;
public LoginAsyncTask(String strGoogleUserType, String strGoogleNickName, String strGoogleDisplayName, String strGoogleID,
String strGoogleCurrentLocation, int iGoogleCircledByCount, String strGoogleEmail, String strGoogleBirthday,
String strGoogleGender, String strProfilePhotoUrl, String strAndroidDeviceId, Date dat) {
MyApi.Builder builder;
if (m_debug) {
builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
// options for running against local devappserver, from device
.setRootUrl("http://192.168.1.4:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
}else {
builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null);
}
builder.setApplicationName("myApp");
m_suaMyApi = builder.build();
try {
if (strGoogleBirthday == null){
strGoogleBirthday = "";
}
if (strAndroidDeviceId== null){
strAndroidDeviceId = "";
}
if (strGoogleCurrentLocation== null){
strGoogleCurrentLocation= "";
}
if (strGoogleDisplayName == null){
strGoogleDisplayName= "";
}
if (strGoogleEmail == null){
strGoogleEmail= "";
}
if (strGoogleEmail == null){
strGoogleEmail= "";
}
if (strGoogleGender == null){
strGoogleGender= "";
}
if (strGoogleID == null){
strGoogleID= "";
}
if (strGoogleNickName == null){
strGoogleNickName= "";
}
if (strGoogleUserType == null){
strGoogleUserType= "";
}
if (strProfilePhotoUrl == null){
strProfilePhotoUrl= "";
}
Log.d("myApp", "about to store data");
///////////////BREAKS AT THE NEXT LINE
m_suaMyApi.storeBean(strGoogleUserType, strGoogleNickName, strGoogleDisplayName, strGoogleID,
strGoogleCurrentLocation, iGoogleCircledByCount, strGoogleEmail, strGoogleBirthday,
strGoogleGender, strProfilePhotoUrl, strAndroidDeviceId).execute();
Log.d("myapp", "its stored");
} catch (GoogleJsonResponseException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected String doInBackground(Pair<Context, String>... params) {
// Retrieve service handle.
MyApi apiServiceHandle = m_suaMyApi;
return "Login not saved";
}
@Override
protected void onPostExecute(String result) {
Log.d("myApp", "LoginAsyncTask: finished");
}
}
/////////////////////////////////////////////// //////////////////////////////////////////
我的端点代码响应上面的
@ApiMethod(name = "storeBeanBean")
public void storeTask(@Named("strGoogleUserType") String strGoogleUserType, @Named("strGoogleNickName") String strGoogleNickName,
@Named("strGoogleDisplayName") String strGoogleDisplayName, @Named("strGoogleID") String strGoogleID,
@Named("strGoogleCurrentLocation") String strGoogleCurrentLocation, @Named("iGoogleCircledByCount") int iGoogleCircledByCount,
@Named("strGoogleEmail") String strGoogleEmail, @Named("strGoogleBirthday") String strGoogleBirthday,
@Named("strGoogleGender") String strGoogleGender, @Named("strProfilePhotoUrl") String strProfilePhotoUrl,
@Named("strAndroidDeviceId") String strAndroidDeviceId) {
DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
Transaction txn = datastoreService.beginTransaction();
try {
Key UserkBeanParentKey = KeyFactory.createKey("User", "UserBean");
Entity entUserEntity = new Entity("UserBean", strGoogleID ,UserkBeanParentKey);
entUserEntity.setProperty("m_strUserType", strGoogleUserType);
entUserEntity.setProperty("m_strUserName", strGoogleNickName);
entUserEntity.setProperty("m_strDisplayName", strGoogleDisplayName);
entUserEntity.setProperty("m_strID", strGoogleID);
entUserEntity.setProperty("m_strUserLocation", strGoogleCurrentLocation);
entUserEntity.setProperty("m_iFollowerCount", iGoogleCircledByCount);
entUserEntity.setProperty("m_strUserEmail", strGoogleEmail);
entUserEntity.setProperty("m_strUserBirthday", strGoogleBirthday);
entUserEntity.setProperty("m_strUserGender", strGoogleGender);
entUserEntity.setProperty("m_btmProfilePhoto", strProfilePhotoUrl);
entUserEntity.setProperty("m_strAndroidDeviceId", strAndroidDeviceId);
datastoreService.put(entUserEntity);
txn.commit();
} finally {
if (txn.isActive()) {
txn.rollback();
}
}
}
///////////// 我的代码中报告的错误
W/System.err﹕ com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
W/System.err﹕ at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(Unknown Source)
W/System.err﹕ at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(Unknown Source)
W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.a(Unknown Source)
W/System.err﹕ at com.google.api.client.http.HttpRequest.o(Unknown Source)
W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(Unknown Source)
W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(Unknown Source)
W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(Unknown Source)
W/System.err﹕ at com.electrichappiness.allsmiles.forStorage.LoginAsyncTask.<init>(Unknown Source)
W/System.err﹕ at com.electrichappiness.allsmiles.Login.onConnected(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.fg.a(Unknown Source)
W/System.err﹕ at com.google.android.gms.common.api.b.e(Unknown Source)
W/System.err﹕ at com.google.android.gms.common.api.b.d(Unknown Source)
W/System.err﹕ at com.google.android.gms.common.api.b$2.onConnected(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.fg.a(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.fg.a(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.ff$h.a(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.ff$h.a(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.ff$b.b(Unknown Source)
W/System.err﹕ at com.google.android.gms.internal.ff$a.handleMessage(Unknown Source)
W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err﹕ at android.os.Looper.loop(Looper.java:157)
W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5872)
W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:668)
W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)