GoogleJsonResponseException:404使用谷歌应用程式端点引擎的后端未找到 [英] GoogleJsonResponseException: 404 Not Found using google apps endpoint engine backend

查看:343
本文介绍了GoogleJsonResponseException:404使用谷歌应用程式端点引擎的后端未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也跟着下面的教程。

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

基本上增加了GAE后端我现有的应用程序。然后我尝试下面的例子中,在本地开发服务器上运行它,我得到低于该异常后

出现

 注意结果= endpoint.insertNote(注).execute();

被调用。

  com.google.api.client.googleapis.json.GoogleJsonResponseException:404未找​​到

我的code如下。

 包com.cloudnotes;进口java.io.IOException异常;
进口java.util.Date;进口android.os.AsyncTask;
进口android.content.Context;
进口com.cloudnotes.noteendpoint.Noteendpoint;
进口com.cloudnotes.noteendpoint.model.Note;
进口com.google.api.client.extensions.android.http.AndroidHttp;
进口com.google.api.client.http.Htt prequest;
进口com.google.api.client.http.Htt prequestInitializer;
进口com.google.api.client.json.jackson.JacksonFactory;
进口android.os.Bundle;
进口android.app.Activity;进口android.view.Menu;公共类MainActivity延伸活动{    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);      新EndpointsTask()执行(getApplicationContext());
    }    @覆盖
    公共布尔onCreateOptionsMenu(菜单菜单){
        。getMenuInflater()膨胀(R.menu.activity_main,菜单);
        返回true;
    }    公共类EndpointsTask扩展的AsyncTask<语境,为Integer,Long> {
        保护龙doInBackground(上下文语境...){          Noteendpoint.Builder endpointBuilder =新Noteendpoint.Builder(
              AndroidHttp.newCompatibleTransport(),
              新JacksonFactory(),
              新的Htt prequestInitializer(){
              公共无效初始化(HTT prequest HTT prequest){}
              });
      Noteendpoint终点= CloudEndpointUtils.updateBuilder(
      endpointBuilder).build();
      尝试{
          注意注意=新的注()setDescription(注意说明)。
          字符串noteID =新的日期()的toString()。
          note.setId(noteID);          note.setEmailAddress(电子邮件地址);
          注意结果= endpoint.insertNote(注).execute();
      }赶上(IOException异常五){
        e.printStackTrace();
      }
          返回(长)0;
        }
    }
}


解决方案

这归结为应用程序引擎默认版本是从您已经部署的不同。到这里:
https://appengine.google.com/deployment?app_id=s~your -project-ID
并更改默认版本

I followed the tutorial below.

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

which basically added a GAE backend to my existing app. I then try out the example below, run it on the local development server and I get the exception below which occurs after

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

is called.

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

My code is below.

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;
        }
    }
}

解决方案

This comes down to the app engine default version being different from the one you've deployed. Go here: https://appengine.google.com/deployment?app_id=s~your-project-id and change your default version

这篇关于GoogleJsonResponseException:404使用谷歌应用程式端点引擎的后端未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆