android – GoogleJsonResponseException:404 Not Found使用谷歌应用程序端点引擎后端

我按照下面的教程.

https://developers.google.com/eclipse/docs/running_and_debugging_2_0

它基本上为我现有的应用程序添加了GAE后端.然后,我尝试下面的示例,在本地开发服务器上运行它,然后我得到下面发生的异常

Note result = endpoint.insertNote(note).execute();

叫做.

com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found

我的代码如下.

package com.cloudnotes;

import java.io.IOException;
import java.util.Date;

import android.os.AsyncTask;
import android.content.Context;
import com.cloudnotes.noteendpoint.Noteendpoint;
import com.cloudnotes.noteendpoint.model.Note;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestinitializer;
import com.google.api.client.json.jackson.JacksonFactory;


import android.os.Bundle;
import android.app.Activity;

import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

      new EndpointsTask().execute(getApplicationContext());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main,menu);
        return true;
    }

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

          Noteendpoint.Builder endpointBuilder = new Noteendpoint.Builder(
              AndroidHttp.newCompatibleTransport(),new JacksonFactory(),new HttpRequestinitializer() {
              public void initialize(HttpRequest httpRequest) { }
              });
      Noteendpoint endpoint = CloudEndpointUtils.updateBuilder(
      endpointBuilder).build();
      try {
          Note note = new Note().setDescription("Note Description");
          String noteID = new Date().toString();
          note.setId(noteID);

          note.setEmailAddress("E-Mail Address");      
          Note result = endpoint.insertNote(note).execute();
      } catch (IOException e) {
        e.printstacktrace();
      }
          return (long) 0;
        }
    }
}

解决方法

导致此问题的另一个可能原因是未在appengine-web.xml中设置正确的applicationId:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>APPLICATION_ID_HERE</application>

</appengine-web-app>

相关文章

###实现效果*本实例主要实现用ViewPage和Fragment实现选项卡...
一、安装 JDK 下载JDK最新版本,下载地址如下: http://www....
这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...