I am developing an Android app that uses Google Cloud Endpoints on Google App Engine (in Python) for its backend. The Android app authorizes the user using Google Play Services on the Android device, and it all works fantastically.
However, now that I have actual users, I'd like to be able to test this all locally before deploying any app engine API changes to production, and I haven't figured out how to have the Android app talk to my local development server anywhere. The testing recommendations suggest that I just do some manual tinkering with API Explorer, but as I'm using the Endpoints Proto Datastore for my API, which makes the Android development easy, it also makes the API Explorer basically useless, since the calls I need to make are far more complicated than what I can generate by hand.
One answer to this question suggests that there is a way to point the Android client at the local server, but while I can use the --host argument to have the dev_appserver's default server listen on something other than localhost, I can't seem to find a way to do the same for the API server. And even if I could do that, it might only be the first step to a full end-to-end local testing setup for my Android app.
Can someone post more details on how I might do this, or short of that, please enlighten me on the best practices for testing Android apps that use Google Cloud Endpoints on App Engine? Thanks in advance for any answers.
Alright, finally got it working, thanks for the tips, Dan! Here are the remaining details that would have saved me a few hours - hopefully this is helpful to someone else.
1) As I expected and mentioned earlier, dev_appserver.py needs to be run with --host=0.0.0.0 so that it can listen on the local network.
2) In order to properly parse the ID token to make the user authentication work, you need to have the PyCrypto library installed - it is not installed by default, so just having it in your app.yaml isn't enough. I found the binaries for Windows here.
3) Then, in my generated Tictactoe.java-equivalent class, I had to change the DEFAULT_ROOT_URL to be http://<my-local-machine>:8080/_ah/api/
(which is where my local machine is running), so that requests went to the local network. Alternatively (and perhaps less invasively), you can use builder.setRootUrl to the same address from wherever you initialize your builder. This way you don't muck with your generated classes.
4) I also had to make the change Dan mentioned described here.
After doing those four things, everything seems to be working now and I can test my app locally - hooray!
In the local environment, the dev_appserver is the API server. If you've configured it so that it's accessible from machines other than localhost (i.e. another machine/device on the network) API requests should be accessible as well.
However, there's currently an issue with the local server and gzipped requests. Until that's fixed you'll need to disable gzipping within the client library in your Android app (see this post).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With