I am making an app which requires connection with my localhost on PC. It is working fine with emulator but when trying it out in my real device it is throwing exception:
org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.XX.XX:8090 refused, network host unreachable etc etc
where 8090 is the port in which my Apache Tomcat is running and 192.168.xx.xx is my pc's ip address. I have tried out many things but none worked. Also I'm using USB connection not wifi to access localhost from device.
Please help!!!! thanks
Have you looked at similar questions linked by Stackoverflow, such as Cannot access localhost from Android device or How can I access my localhost from my Android device??
This question does not have a single answer, there can be many different problems. You do not list what you tried to exclude.
Also, can you paste the actual error without removing technical details? You can omit the stack trace. Can you add the line doing the connection?
As a first step, since the message says "network host unreachable" you should check that your phone can access your computer at all. Try navigating to http://192.168.XX.XX:8090 with your phone's browser, if that succeeds probably there's a problem in your app (the code, permissions, etc.).
If that fails you have more subquestions, which are general network troubleshooting questions:
- can the phone indeed reach the IP of your PC? If yes:
- does the webserver listen for outside connections? If yes:
- what is blocking the connection between phone and webserver? Is there any firewall involved? For this one, understanding how networking works "inside", that is, which nodes are supposed to relay the packets to the other side, will tell you which nodes might not be doing their job. (With a USB connection, that's the two hosts themselves).
Maybe you did some of the experiments and excluded some of these hypotheses. If so, it would be helpful to describe those experiments. If you are not doing that, and you want to learn to troubleshoot better, you might look into the scientific method for troubleshooting (Google "troubleshooting scientific method", there are several essays which look helpful, like this).
It is probably your manifest file is corrupted. Even I was getting same error; while I checked my logcat closely, I found that some permissions were 'not recognized'.
So, check your manifest permissions, or re-write them, it will solve your problem.
Related
I've developed an Android application which worked fine on my side but failed (not crash) on client side.
I do the research but still can't figure how to do.
From this post Debugging android device over the Internet
I know it can achieved by using abd, but it required both pc connect on the same network, which are not suitable for my case where my client are connect on difference network.
This post suggest another solution which is port forward, but warmed not recommended as this was pretty dangerous.
The following post suggest method of adb -a -P 5037 nodaemon server but I'm not really understand does it work for my situation as i getting error of could not install *smartsocket* listener: cannot bind to 0.0.0.0:5037: Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048)
My question is how do remotely debug (get the logcat) of client application under difference network but was able to connect on the same VPN. Thanks.
Even i had faced the similar problem and this blog talks on same thing and there is some solution already out there which can be used for working on remote android devices, it looks paid one though.
I'm not sure if this is possible, I'm trying to redirect traffic from a mobile app that is connected to the internet through a hotspot wifi from my laptop. The app is Sending requests to a cloud server, and the idea is that the traffic should first go through a proxy that is listening to a local port in my laptop, as per this rough sketch:
I believe this could maybe be solved using iptables, but I'm using Windows, I've looked into netsh but so far I haven't found a command (such as portproxy) that suits my needs, partly because I don't know if this is possible at all. I'm purposefully being a bit general here but if there's any questions we can go more in-depth.
Can someone give me a hint here?
I have local database and Android app in Genymotion. I want to send POST JSON without internet. Both sides of code is ok on USB Device and database with WIFI connection. My database is written on ASP.Net web api 2 with azure functions.I tried to use different URL's
http://198.168.67.2:7071/api/LogIn
http://10.0.3.2:7071/api/LogIn
http://10.0.3.15:7071/api/LogIn
and nothing happened.
So, my question is: Can I send POST without internet using Genymotion and if yes how can I do this.
Thanks for help.
In order to do that, you'll need to connect the both desktop and your Android device (such as emulator or a real device) to a network which has a router.
Router will do the rest and it does not matter if it has internet connection or not.
So the solution will be that connecting both Desktop and the Android device to a local network which they can find the eachother.
Remember to add the Internet permission in the AndroidManifest.xml.
Check this link for more information.
This one.
And this one too.
My scenario is as follow:
I'm working with an app development which a bug occurs in the app when it is in a different country than mine, and only there. The bug is related with a fail in an image download through an URL access. Right now, I haven't figured out yet what it can be. Some subjects I've already looked up are:
Its not related to internationalization and/or culture, because the code does not implement this;
Its not related to firewall/security access, because if the user in the other country opens the image's URL, he can look at the image;
Without rooting the device, is there is a way to remotely open and debug a given Android device, just like a SSH or a VNC?
Similar questions are:
Debugging android app on a device remotely
Remote Debugging
Well,
you can debug a device using a TCP/IP connection (I sometimes debug using WIFI at home). all you need to do is make sure the remote device is connected to the internet and is accessible to your PC with a direct TCP/IP connection.
As the Android device is connected in another location - you'll have to make sure your router's firewall allows outgoing connection for communications in the port ADB is using , and that the target Android device receives communications in that port (if it's behind a router - the router should allow connections under the righ port and forward all comm in that port to the android device).
in other words - you have to "tunnel" your communication to the target device. there are other tunneling solutions/products but I've never used them and I prefer the "manual" way
Good luck,
Dan
EDIT : in Android 11 - adb can work on WIFI natively : https://developer.android.com/studio/run/device#wireless
Perhaps you can have the user install something like aLogcat and have them send you a log with the failure.
Well as remotely debugging a device I don't know but you can use ACRA (Application Crash Report for Android) .
All you need is to set up a google doc, add the lib to your project and when the app crashes it will send a crash report to that google doc. See quick setup here
I am facing a strange problem with my Android ACE phone. I am able to connect to Wi-Fi and able to browse Google. But unable to connect to my Internal Servers / network. What is the problem? Will it be an issue with the device or is it the problem with router? Same Server is accessible through my IPAD2!!
My client is telling me that they have not blocked my device from accessing their network.. But my device displays "DNS Error" when i try hitting their server.
So is there any way that I can detect if my user agent or device is blocked by the internal router or network??
Thanks in advance,
Sneha
First of all this is not the place to ask this type of questions. This site is for development/programming related questions. Why don't you use https://android.stackexchange.com/. However I think your issue can be fixed by using custom DNS servers like 8.8.8.8 or 8.8.8.4. Or you could run a port scan on your network and see if they have a DNS server.