[英]Appengine connected Android prj got 404 on mobile test
我啟動並運行了android + appengine應用程序(端點),在我的本地計算機上一切正常,因此我決定上傳我的appengine代碼,以便嘗試直接在手機上通過Android應用程序訪問數據。
當我嘗試致電我的Appengine后端時,出現404錯誤。
在瀏覽器上,如果我嘗試致電http:// [myAppID] .appspot.com / _ah / spi,則會得到:
Error: HTTP method GET is not supported by this URL
所以主要的天鵝絨娃娃正在回應,我在做什么錯?
(已授予Internet許可!)
提前致謝!!
這是代碼,這是在AsyncTask內部執行的:
Builder endpointBuilder = new Myendpoint.Builder(AndroidHttp.newCompatibleTransport(), new JacksonFactory(), new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) {
}
});
Myendpoint endpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build();
try {
MyUsers result = endpoint.searchMyUser(params[0]).execute();
return result.getItems().get(0);
} catch (Exception e) {
e.printStackTrace();
return null;
}
這是CloudEnpointUtils內部的代碼(顯然LOCAL_ANDROID_RUN設置為false):
public static <B extends GoogleClient.Builder> B updateBuilder(B builder) {
if (LOCAL_ANDROID_RUN) {
builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/");
}
// only enable GZip when connecting to remote server
final boolean enableGZip = builder.getRootUrl().startsWith("https:");
builder.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
public void initialize(JsonHttpRequest jsonHttpRequest) {
jsonHttpRequest.setEnableGZipContent(enableGZip);
}
});
return builder;
}
我為錯誤添加logcat:
10-04 11:40:22.770 W/System.err(13564): com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
10-04 11:40:22.770 W/System.err(13564): Not Found
10-04 11:40:22.775 W/System.err(13564): at com.google.api.client.googleapis.services.GoogleClient.executeUnparsed(GoogleClient.java:279)
10-04 11:40:22.775 W/System.err(13564): at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:207)
10-04 11:40:22.775 W/System.err(13564): at com.appspot.api.services.myuserendpoint.Myuserendpoint$SearchMyUser.execute(Myuserendpoint.java:702)
10-04 11:40:22.775 W/System.err(13564): at it.my.my.app.core.MyBusinessDelegate$MyUserGetter.doInBackground(MyBusinessDelegate.java:303)
10-04 11:40:22.775 W/System.err(13564): at it.my.my.app.core.MyBusinessDelegate$MyUserGetter.doInBackground(MyBusinessDelegate.java:1)
10-04 11:40:22.780 W/System.err(13564): at android.os.AsyncTask$2.call(AsyncTask.java:264)
10-04 11:40:22.780 W/System.err(13564): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-04 11:40:22.780 W/System.err(13564): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-04 11:40:22.780 W/System.err(13564): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
10-04 11:40:22.785 W/System.err(13564): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-04 11:40:22.785 W/System.err(13564): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-04 11:40:22.785 W/System.err(13564): at java.lang.Thread.run(Thread.java:856)
編輯:AppEngine DeployLog
------------ Deploying frontend ------------
Preparing to deploy:
Created staging directory at: 'C:\Users\XXXXXXXXX\AppData\Local\Temp\appcfg1884750854541661749.tmp'
Scanning for jsp files.
Compiling jsp files.
Scanning files on local disk.
Initiating update.
Cloning 1 static files.
Cloning 66 application files.
Deploying:
Uploading 0 files.
Initializing precompilation...
Deploying new version.
Verifying availability:
Will check again in 1 seconds.
Will check again in 2 seconds.
Will check again in 4 seconds.
Closing update: new version is ready to start serving.
Updating datastore:
Uploading index definitions.
Deployment completed successfully
EDIT2:其他信息
我已經嘗試過與應用引擎大戰中使用過的Java servlet進行通信,通過瀏覽器沒有任何問題,一切正常,如果我嘗試從命令行ping或嘗試以編程方式進行通信,則會遇到此錯誤:
"Unable to resolve host "[myappID].appspot.com": No address associated with hostname"
請任何人幫助我找到解決方案
編輯3:好消息,我已經能夠使用以下版本的appengine地址來調用我的servlet:
http://[version].[myAppID].appspot.com/myServlet
代替:
http://[myAppID].appspot.com/myServlet
我不知道為什么,但是這樣有效! 即使使用版本地址技巧,嘗試通過終結點調用遠程appengine應用程序仍然不走運,希望此幫助!
根本原因是您的代碼中使用的版本與App Engine默認版本不同。
該應用引擎的默認版本已部署到:http:// [appversion] -your-product-id.appspot.com您正在運行的代碼已將部署版本指定為1,這意味着在部署時,您的應用將在此處進行檢查: http://1-dot-your-project-id.appspot.com,因此是404(因為從本質上講,此URL不會退出。在這里我僅出於說明目的使用它)。
要解決此問題,請轉到https://appengine.google.com/deployment?app_id=s~your-project-id ,然后將您上傳的版本設為默認版本
此處更多內容: App Engine設置問題
看起來您尚未被信任的測試人員計划接受。 除非您處於TT程序中,否則這將無法工作。 您可以在此頁面上注冊:
http://endpoints-trusted-tester.appspot.com/
如果接受,您將收到一封電子郵件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.