Testing Java Endpoints on real device in Android Studio - android

I followed this tutorial to setup a cloud database for my Android App
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints
Everything compiled fine and the server is running at http://localhost:8080/
However I keep getting this error
failed to connect to /10.0.0.2(port 8080) after 20000ms
I tried replacing 10.0.0.2 with my local IP address but it didn't work and showed the same error.
I am using Android Studio and debugging the app on my Android phone. Kindly help. Thanks!

Couple of areas to check:
Make sure you can connect to your locally running server using local IP address. In in your computer browser go to :8080. If it doesn't work then make sure your Run/Debug Config in AS is calling 127.0.0.1 or 0.0.0.0 address.
your android app has to be calling your pc's local IP address.

You need to start the dev server listening on 0.0.0.0. By default, the dev server listens only on localhost which means requests from other devices will not work. Just edit your run configuration and set the server address.

First find the IP Address of your machine (e.g., 192.168.x.x), by using ifconfig.
Change your build.gradle file of the endpoints project by adding this code appengine.run.host='192.168.x.x' at the end of the file.
Change the address in your android code with .setRootUrl("http://192.168.x.x:8080/_ah/api")

Related

emulator can't connect to Google App Engine dev server

In my Android emulator, I was able to contact the GAE dev server.
I use this url: "http://10.0.2.2:8080/myurl".
The server is listening on http://127.0.0.1:8080.
Then, after I've updated the emulator to the Nexus 5X version with Google Play(API 27), the connection fails and the server show this log:
ERROR 2018-01-11 11:17:05,463 wsgi_server.py:329] Request Host 10.0.2.2 not whitelisted. Enabled hosts are set(['127.0.0.1'])
I'm using the latest GAE python SDK with webapp2.
Any idea on how to solve the problem?
The more recent versions of the development server includes whitelisting checks of the source IP address of incoming requests.
You can use the --enable_host_checking=False command line option for the GAE devserver, which disables these checks. Not a good idea if you're running on an untrusted network.
You're probably seeing such errors even for accessing the devserver from the same machine. Another option for these requests would be to use the --host 10.0.2.2 devserver option (i.e. use your machine's external IP address instead of localhost/127.0.0.1, but that won't help with the emulator requests if you're running the emulator on some other machine.
Ideally the whitelist should IMHO be manageable independently from the server's IP address, but this is what is available presently.

Can't access HTTPS from my Android Emulator

I'm behind a corporate proxy and everything that access the internet needs a special configuration regarding Proxy. I'm on a CentOS 7, using CNTLMD to handle proxy tunneling, developing for mobile with React Native. And I'm using the Android Emulator provided by Android Studio.
I first noticed that my emulator can't access any HTTPS protocol when I tried to open Google in the Browser. Internally google redirects to HTTPS and I always get that "Connection Refused" error. Later (this week), trying to use Axios and Fetch to make HTTP/HTTPS requests, this has become a serious problem, since the APIs I'm trying to connect to are under the HTTPS protocol.
A friend of mine who is working in the same project but using Mac has no problems with HTTPS. I have also tried to start the emulator with the following commands:
emulator -avd myemulator -http-proxy http://127.0.0.1:3128
And
emulator -avd Marshmallow86 -http-proxy http://<network username>:<network password>#<ip>:<port>
And they do nothing.
I tried setting up HTTP and HTTPS proxy on Android Studio but this don't seem to be the way (and also didn't work).
#edit
I set the http_proxy on my host and started the emulator without parameters. Didn't work as well.
What am I missing?
I haven't used the software above that isn't android avd or androidstudio,
but it looks like a proxy or CA certificate problem.
Since the difference seems to be by OS, I would guess CA certificate first.
This android page has advice on using openssl from the command line to
explore that and consider importing certificates.
https://developer.android.com/training/articles/security-config.html
This android page has current suggestions for proxy configurations:
https://developer.android.com/studio/run/emulator-networking.html
Note, that the above instructions are updated for new features.
In the past I needed a proxy to a non-ssl appengine development server
which is slightly different from your problem but here's what I used:
For an SSL proxy, used the apache web server, and configured it to use SSL
by installing a self-signed certificate, then added a ProxyPass and ProxyPassReverse
in httpd.conf and a ProxyPass in the httpd-ssl.conf.
ProxyPass / http://127.0.0.1:8080/
Apache as an SSL proxy receives connections to https://127.0.0.1:443 and
passes them to http://127.0.0.1:8080
Then in the application, code that will be running in the emulator
can use address
10.0.2.2 to use android subnet routing table to connect to the dev. OS localhost.

Cannot access to app engine local dev server

I'm devellopping an android app for my school project using android studio, I create a google app engine endpoint to acces a datastore, I follow those two tutorial:
http://rominirani.com/2014/08/26/gradle-tutorial-part-9-cloud-endpoints-persistence-android-studio/
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints
So i create a new Module, put my google app id into the appengine-web.xml file, when I run it I get te message:
INFOS: The admin console is running at http://localhost:8080/_ah/admin
nov. 25, 2014 3:46:33 PM com.google.appengine.tools.development.DevAppServerImpl doStart
INFOS: Dev App Server is now running
But here is my localhost
I also try to change the port number in my gradle file by writing:
appengine {
httpPort = 8080
But I obtain another error:
Do anyone have an idea why my dev server isn't accessible ?
You seem to try with port number 8888 (look at your error message), where as your server is running at 8080 port number
If you want to change the port number, there is an .iml file inside the project, edit HTTP_PORT under configurations{}
I found out the error was prompt only with gogle chrome (maybe because i'm running it without admin privileges) but it's works great in safari.

Google App Engine conneced Android App Failure

I trying to deploy an android application connected to GAE. I run the online tutorial on google, I used the right configuration (as they write on the tutorial) but I can't communicate the Android Virtual Device with the web application running locally. The Web application shows me a "Server Error 500" and the android application on AVD shows me a "Failure:Connect to /192.168.56.1:8888 timed out" error.
I m running Eclipse Indigo and the virtual android device is with Google API Level 10.
Thank you.
Appengine dev server by default only accepts connections on localhost address (localhost and 127.0.0.1).
To make it accept connections on all ports add -bindAddress 0.0.0.0 to dev server parameters in Eclipse.

Develop in the cloud, but Debug Android App on local device over USB over Remote Desktop

I have been able to install Eclipse, with the android SDK, and get my android app to compile, DEBUG and run on a local desktop.
Now I would like to do the same, but over a connection to a remote desktop, basically a server in the cloud.
Any ideas on what is required to do this? I am especially interested in debug.
I have tried just simply connecting the device and enabling it in remote settings. Is there something else I need to enable/install? Is there something I need to configure on the ADB bridge?
This app may help:
ADB port forward
I am assuming you mean using Eclipse to debug the application running on the device. If this is correct, this documentation page may help.

Categories

Resources