简体   繁体   中英

Appengine connected Android prj got 404 on mobile test

I got my android+appengine application (endpoint) up and running, everything works fine on my local machine, so I decided to upload my appengine code so that I can try accessing data through the Android application directly on my mobile phone.

When I try to call to my appengine backend, I got 404 error.

On browser if I try to call for http://[myAppID].appspot.com/_ah/spi I get:

Error: HTTP method GET is not supported by this URL 

So the main serlvet is responding, what am I doing wrong??

(Permission for Internet granted!)

Thanks in advance!!

here's the code, this is executed inside an 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;
        }

This is the code inside CloudEnpointUtils (obviously LOCAL_ANDROID_RUN is set to 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;
}

I add the logcat for error:

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)

EDIT: 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: other infos

I've tried to communicate with a java servlet I've put in appengine war, via browser there's no problem everything is working fine, if I try to ping from command line or try to communicate programmatically I have this error:

"Unable to resolve host "[myappID].appspot.com": No address associated with  hostname"

Please anybody help me find a solution

EDIT 3: Good news, I've been able to call my servlet using the appengine address with version that is:

http://[version].[myAppID].appspot.com/myServlet

instead of:

http://[myAppID].appspot.com/myServlet 

I don't know why but this way it'works! Still no luck trying to call remote appengine app via endpoint even using version-address trick, hope this help!

The root cause is that the version being used in your code is different from the app engine default version.

The app engine default version is deployed to: http://[appversion]-your-product-id.appspot.com The code you are running though has specified the deployment version as 1 which means when deployed, your app will check here: http://1-dot-your-project-id.appspot.com hence the 404 (because in essence, this URL doesn't exit. I use one here for illustration purposes).

To resolve this, go to https://appengine.google.com/deployment?app_id=s~your-project-id and make the version you've uploaded the default version

More here: App Engine Set-up hiccups

Looks like you have not been accepted to the trusted tester program. This will not work unless you are in the TT program. You can sign up at this page:

http://endpoints-trusted-tester.appspot.com/

You will receive an email when(if) accepted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM