Recently I see that is possible to debug app development by use WIFI instead of USB debug method. I make a search and I found an app called abdWireless but I have a problem.
How I can tell to Eclipse to connect via Wifi method?
I think that it is an automatic process, but on start debug it open the Emulator.
Someone? :)
Bye
First, run 'adb connect ip:port', like adb connect <phone-ip-address>, from console/terminal (with your IP address and port of cause). This makes adb service to connect to your device via network.
Port 5555 is used by default if no port number is specified.
Then check that device is correctly connected: run adb devices from console/terminal (make sure you remove usb cable from device). If adb devices does not list your device, then you have some entirely different issue.
If you've connected your device via adb and you can see the device in adb devices list, but your eclipse still starts emulator,:
Go to Run->Debug Configuration -> [your configuration]
In your configuration go to Target tab and select Manual
This will popup device selection each time you start the app from eclipse. So you will be able to explicitly state which emulator/device to use.
To disconnect your device, adb disconnect <phone-ip-address>
This process can be automated from within Eclipse with Adb Connect:
http://ppareit.github.com/AdbConnect/
I'll try to explain how I connected eclipse with my android device with adb thru wifi on my win7 x32, sharing my internet connection at the same time.
I'm using two methods.
The first one is when my computer is connected the internet (ie. thru ethernet cable), and I'm sharing this connection with my android device thru wifi (like a hotspot).
The second one I use when my computer isn't connected directly to the internet, yet I'm using my device's internet to connect my computer to the internet.
Computer connected to the internet, android device connected to the internet thru my computer.
Note that for this to work, your wireless card must meet certain requirements, as this won't work with all wireless cards.
Well first of all, you need to share your internet connection from your computer. To do that open cmd (command prompt) with administrative privileges (press the win logo, type cmd, and then press ctrl+shift+enter). To set up the "hotspot", type:
netsh
wlan
set hostednetwork mode=allow ssid=Hotspot key=D2D46784ECB32 keyUsage=persistent
start hostednetwork
Change "Hotspot" to whatever you want your ssid to be called. Change "D2D46784ECB32" to whatever you want your key (WPA2) to be.
Now, go to Control Panel\Network and Internet\Network Connections. You'll probably notice a new "adapter" called "Wireless Network Connection 2". Right click on the ethernet connection (or whatever device you use to connect to the internet). Click on properties. Click on sharing. Check the "Allow other network users to connect through this computer's Internet connection". Select the Wireless Network Connection 2. Click OK. What you just did was to start Internet Connection Sharing (ICS).
The next step is to connect your device to the connection you've just created. On your Android device, search the wifi connection, which you'll find by the ssid you've set (ie. Hotspot), and enter the key you've set (ie. D2D46784ECB32). Once the connection has been established, you'll have Internet access.
Please note that sometimes I have trouble with this connection. Sometimes my device is unable to connect (I think that there is a bug in win7). I usually fix this by going to my computers connections, and on my ethernet connection I go to properties → sharing, uncheck the "Allow other...". Click OK. Then again go to that connection's properties → sharing and check the "Allow other…". Basically I've reset the ICS. And now I'm usually able to connect.
Please also note that once you've restarted your computer, I'll most probably have to restart the hostednetwork and reset the ICS.
To stop the hotspot, type:
stop hostednetwork
To start the hotspot, type:
start hostednetwork
Note that you don't have to set the hostednetwork again, just start it. Please also note that you must be in the netsh - wlan mode, (type netsh and then wlan, as before), and the cmd must have been started with the administrative privileges.
Now, if you haven't already done it, turn on your developer options in your android device and turn on ADB over network. After that you'll most likely see an ip address, suffixed by
:5555
ie.:
192.168.137.158:5555
On your computer, open cmd, go to your adt/sdk/platform-tools folder. On my computer it's like this:
cd "C:\Program Files\adt-bundle-windows-x86\sdk\platform-tools"
And type the following:
adb connect 192.168.137.158
You should replace the ip address with the one that was shown in your android device in the developer options. (I didn't need to add the :5555 suffix/port, but you may need to do it).
To check whether the connection was successful, type:
adb devices
(Btw, i'd like to thank inazaruk for his help with this).
Now, you should be able to connect eclipse with your android device thru wifi, as others have explained (run configuration → target → manual).
Computer not connected to the internet. You are using the internet connection of your android device to connect the computer to the internet.
On your Android device, go to Settings → More → Tethering and portable hotspot → Set up wi-fi hotspot. Change the SSID, the key and the security as you please.
Go back one step and turn on Portable Wi-fi Hotspot.
On your computer, connect to your android device via wifi as you'd do with any other wi-fi connection, with the ssid and key that you've set.
Once you've connected, go to Control Panel\Network and Internet\Network Connections, right-click on the wireless connection you've just connected to. Select Status and then Details. Find the IPv4 address of your computer (at least I'm using IPv4, you might use IPv6).
That address might be like this:
192.124.159.52
The default gateway should then be like this:
192.124.159.1
On your computer, open cmd, go to your adt/sdk/platform-tools folder. On my computer it's like this:
cd "C:\Program Files\adt-bundle-windows-x86\sdk\platform-tools"
And type the following:
adb connect 192.124.159.1
You should replace the ip address with the one that was shown default gateway (I didn't need to add the :5555 suffix/port, but you may need to do it).
To check whether the connection was successful, type:
adb devices
(Btw, i'd like to thank inazaruk again for this).
Now, you should be able to connect eclipse with your android device thru wifi, as others have explained (run configuration → target → manual).
Computer and android device connected to the internet via the same wifi modem.
I must admit that I haven't tried this option, but I'm guessing that it's similar as the two methods before. Find the IP address of the android device in the developer options (you should be able to see it when you enable ADB over network). And then on your computer, as before:
open cmd, go to your adt/sdk/platform-tools folder. On my computer it's like this:
cd "C:\Program Files\adt-bundle-windows-x86\sdk\platform-tools"
And type the following:
adb connect <ip_address_of_your_android_device>
.
To check whether the connection was successful, type:
adb devices
Now, you should be able to connect eclipse with your android device thru wifi, as others have explained (run configuration → target → manual).
Now, I know that this isn't exactly the answer to the question. But I did find it very hard to share my internet connection, and then to use the wifi with eclipse to develop apps. After some time, I managed to connect like I've described. So, if I've helped someone to do the same, I'd be very happy :-)
Related
I installed the Android WiFi ADB plugin to run the app wirelessly. But it's not working it's giving error that Phone and PC should be connected on the same network. I use my phone hotspot to run the internet on my PC. Then I use another phone but then also same error. Someone says it will not work because you use the mobile hotspot for an internet connection on your PC. But when I try to connect another phone then also the same issue. But the same way my friend also does. he also uses the internet using a mobile hotspot but it's working fine on his phone. I have a POCO F1 Phone.
I'm answering this hoping this may help others as well as I find it helpful for my use.
First, Turn on ADB in your phone's developer options. You can search Your_phone_model developer options to find that.
Second, After turning on ADB, Connect your phone with data cable to your laptop/desktop.
Open a Command prompt window, Type adb tcpip 5555, Press allow in adb prompt shown in your phone, it will show restarting adb in tcpip mode. Now, disconnect the USB cable. You can use different port number to connect another device.
Type adb connect your_phone_ip:5555 as for example adb connect 192.168.43.1:5555 in case of hotspot. You can check Phone's IP in WIFI's advanced setting of your phone or in status section.
Now, Everytime your device restarts, repeat steps 3-4.
You can also make a script, just type adb connect your_phone_ip:5555 in a notepad file, save it as name.bat file, right click on it and send to desktop (create shortcut), in the settings on the shortcut, set any shortcut keys. Now, anytime you want to connect, just press the shortcut keys. That's how I do it. You can further open Android studio by this script so it will open Android Studio as well.
Remember, whenever it says Device is Offline, restarts your phone's wifi and reconnect it.
I have a development environment set up in a Hyper-V virtual machine (Windows 10). Using Visual Studio 2019 as my IDE with Xamarin (a monodroid project).
My physical device is unable to "passthrough" due to decisions made by the Hyper-V designers, from what I've read.
I have also tried to use workarounds, unfortunately, the device does not show up (even in Device Manager) in the Guest machine.
I was unable to see the device (within the IDE) initially, however, after some research and work, I've managed to get the device showing. I used this to "trick" adb running on the Guest to see the device (which is connected to my physical machine).
Host machine runs the script with IP 192.168.1.13 on port 6037 (adb daemon runs on 5037, which is default). Guest machine runs the script, with remotehost set to the Host IP, with the same port. I believe this configuration is fine, according to the documentation.
Unfortunately, even though I am able to deploy to my device, the debugger is unable to connect, and I receive Cannot start debugging: Cannot connect to 127.0.0.1:29300: No connection could be made because the target machine actively refused it 127.0.0.1:29301
Couldn't connect debugger. You can see more details in Xamarin Diagnostic output and the full exception on logs.
From what I have gathered, the debugger is trying to connect to localhost, and since the IDE is running within the Guest, the physical device will not be at localhost:29301. I assume if I could get the IDE to connect to 192.168.0.13:29301 (Host IP) instead, it would find the device, given that's where it is connected.
When I run adb devices, both the Host and Guest show the physical device, and after attempting to run the debugger, running adb forward --list, the forward rules are as such:
V4QBB18807150883 tcp:29300 tcp:29300
V4QBB18807150883 tcp:29301 tcp:29301
I can also see in Xamarin Diagnostics that setprop "debug.mono.extra" "debug=127.0.0.1:29302:29303,timeout=1585047190,loglevel=0,server=y" is executed. I assume manipulating that would give me some joy, but, I don't know how.
I'm not too familiar with adb and networking, so anyone with more experience in the matter could shed some light on my situation.
How can I get the debugger (within the Guest) to connect to my physical device?
PS: I've searched a lot before asking here. I know this exists: How can I connect to Android with ADB over TCP? and even after trying multiple answers on that page, I was unable to solve my problem.
After considerable amount of research, I came across this. Instead of searching for a way to set up adb port forwarding, I tried to see if there was a way to set up a USB passthrough via Hyper-V.
If using RDP is an option (directly connecting through "Hyper-V Manager" also works):
On host machine
Press Win+R type gpedit.msc and hit enter
Go to Computer configuration > Administrative templates > Windows Components > Remote Desktop Services > Remote Desktop Connection Client > RemoteFX USB Device Redirection
Select the only GPO there and Enable it and change the access rights to "Administrators and Users"
On VM:
Press Win+R type gpedit.msc and hit enter
Go to Computer configuration > Administrative templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Device and Resource Redirection
Select GPO "Do not allow supported Plug and Play device redirection" and disable it
Reboot both machines...
You may need to force update Group Policy, as per this comment:
I had to force update group policy (gpupdate) for it to take effect. Just shutting down and restarting both host and vm wasn't enough. Thanks
Eventually, after carrying out those steps (I ran gpupdate and restarted both machines), I had an extra option of listed devices, "Other supported RemoteFX USB devices", within that was my physical device. After checking the tick box, the VM detected the device without the need to port forward.
This can potentially cause security risks allowing a passthrough like this, however, my VM is not public and only accessible via my Host.
I would appreciate if someone in security could comment on the possible security risks just to inform myself and potential others that come across this post.
This is an old post but for anyone stumbling upon it, I found an alternative way to connect a physical device to a Hyper-V VM. I was able to get this working on a Hyper-V VM running Ubuntu 20.04. There was no way I could edit the group policy so instead I found a way to connect my VM to the same wifi as my device. Once connected, I could use Android Studio to pair it that way.
I followed the guidance here: https://superuser.com/questions/1403016/how-do-i-setup-a-working-wifi-internet-connection-on-windows-10-hyper-v
Open Hyper-V Manager
Click "Virtual Switch Manager"
Click "New virtual network switch"
Name: NAT, Connection type: "External network", Select the correct network adapter. Tick "Allow management operating system to share this network adapter.
Right click Ubuntu, select "Settings"
In Network Adapter, Virtual switch, select "NAT"
Go to "Control Panel > Network and Internet > Network Connections" in Windows 10
Right click the network adapter that is in use. For me, it is "Ethernet 2"
"Properties > Sharing", tick "Allow other network users to connect through this computer's Internet connection" and select "vEthernet (NAT)" in the drop down.
Tick "Allow other network users to control or disable the shared Internet connection", then OK.
Start Ubuntu virtual machine and test!
Once I followed those steps, Android Studio was able to pair with my device over the wifi.
I'm trying to debug Flutter apps with ADB over TCP, so tried the following (Android connected with USB) according to this:
adb tcpip 5555
adb connect <Android-ip-address>:5555
But I always get unable to connect to <Android-ip-address>:5555: No route to host.
I installed the plugin Android WiFi ADB to Android Studio, but...no hope.
After that, I tried to ping my Android phone from PC with that command ping <Android-ip-address>, but again it failed with that output From <PC-ip-address> icmp_seq=1 Destination Host Unreachable.
Now I tried to do the same thing (PC & phone), however on an another router (Tenda) and it worked like a charm.
So the problem is from my router, which is a D-Link with a firmware version ME_1.03. I searched for "Port Forwarding" and stuff like that, but I don't know what I'm doing and I didn't come up with any result.
What can I do to solve it.
It's not about router type (in case it doesn't use something different from TCP/IP, Lol). You need to double check, that both devices inside one local network.
Without any additional settings on router, your IP address could be like this xxx.xxx.xxx.***. Where part with xxx should be same both both device. When this is done, follow instruction from the source. Please note, you will need to connect devices with USB, before using TCP.
The firmware can be found here below DSL > 2750U, while there are 2-3 different hardware revisions, therefore it is rather unclear which device it actually is - for some revisions there is newer firmware. Generally, the router's network bridge in between wired LAN and WiFi needs to be enabled, in order to connect. Just see the router's manual on page 33 and 45. Without that bridge, you could only connect adb from a notebook, through the same wireless network segment, as the smartphone is connected to (unless "User Isolation" is enabled on the router).
Finally I found it. It's because of a feature (as others said) called WIFI/User Isolation in routers. But in my case, it's called Relay Blocking. Anyway, you have to disable it.
In D-Link (DSL-2740U) - Firmware Version ME_1.03:
Main Page ---> Advanced ---> Advanced Wireless Settings ---> Relay Blocking.
Check disabled choice.
I am developing an Android app, and testing that on a real device.
I have a localhost server set up on my computer, and I want to the device to make request via my computer so that can access to this localhost environment in my computer.
I'm wondering if there is any tool in the adb shell that could allow me to proxy all network activity of the device by my computer, so it can access my localhost service?
NOTE: I know it works on emulator, I am just asking if this is possible on a real device.
Thank you
Install Fiddler on your computer, then on your android device connect to WiFi, long press your wifi configuration and choose modify network, then choose show advanced options and set the proxy field to your PC's IP address
I have an android device (Samsung galaxy tab) connected to my PC via USB .
I want to use WebServices and run a web page which is located on my local xampp server of my PC on my android device .
I can achieve it if I have both , my PC and android device , connected on the same wireless network .
However is it possible to access the localhost page without any wireless connection , using only USB connection .
(PS : This same scenario works when I run the app on an emulator and use the ip 10.0.2.2 to access the localhost on my PC)
Google posted a solution for this kind of problem here.
The steps:
Connect your Android device and your development machine with USB debugging enabled
Open Chrome in your development machine, open new tab, right click in the new browser tab, click inspect
Click the three dots icon on right top side , -> More Tools, Remote Devices.
Look at bottom of the screen, make sure your device name is appeared on the list with Green colored dot.
Look below at the settings part, check the Port forwarding mark
Add rule. Example, if your python web server is running on your machine localhost:5000 and you want to access it from your device port 3333, you type 3333 on the left part, and type localhost:5000, and click add rule.
Voila, now you can access your web server from your device. Try open new browser tab, and visit http://localhost:3333 from your device
I finally solved this problem. I used Samsung Galaxy S with Froyo. The "port" below is the same port what you use for the emulator (10.0.2.2:port).
What I did:
first connect your real device with the USB cable (make sure you can upload the app on your device)
get the IP address from the device you connect, which starts with 192.168.x.x:port
open the "Network and Sharing Center"
click on the "Local Area Connection" from the device and choose "Details"
copy the "IPv4 address" to your app and replace it like: http://192.168.x.x:port/test.php
upload your app (again) to your real device
go to properties and turn "USB tethering" on
run your application on the device
It should now work.
I've read numerous forums and tried play apps but not found a solution until now.
My scenario I believe is similar to yours, but I will clarify to help others. I have a locally hosted website and web services to be used by my android application. I need to have this working on the road for demonstration with only my laptop and no network connection.
Note: Using my iPhone as a wifi hotspot and connecting both my pc and my android device worked, but the iPhone 4S connection is slow and dropped out regularly.
My solution is as follows:
Unplug network cables on PC and turn off wifi.
Turn off wifi on android device
Connect android to pc via USB
Turn on "USB Tethering" in the android menu. (Under networks->more...->Tethering and portable hotspot")
Get the IP of your computer that has been assigned by the USB tether cable. (open command prompt and type "ipconfig" then look for the IP that the USB network adapter has assigned)
Open a browser on the PC using the IP address found instead of localhost to test. i.e. http://192.168.1.1/myWebSite
Open a browser on the android and test it works
I did this on a windows computer and it worked perfectly!
Turn on USB Tethering in your mobile.
Type ipconfig in the command prompt in your computer and find the ipv4 for "ethernet adapter local area connection x" (mostly the first one)
Now go to your mobile browser, type that ipv4 with the port number of your web application. eg:- 192.168.40.142:1342
It worked with those simple steps!
Here is a piece of my Android app's code:
This app is able to communicate with a HTTP get-post model between a servlet running on a server and an Android device plugged in USB-Debuggable mode (because the app was in developing progress).
I also can run the app over Wi-Fi when the server, Tomcat Apache 7, running on (when the app development was finished).
To get the IP address of yours
Go to Command Prompt
Type ipconfig
Hit enter
In the list, IPv4 Address is your IP.
Make sure you have adb installed on the computer, USB debugging enabled on the phone, and the phone has allowed access to the computer. Plug the phone into the computer via USB cable, and make sure it's visible (it should show up in the Bash command adb devices.
In your computer's Chrome browser, open chrome://inspect/#devices, click the "Port forwarding" button, check "Enable port forwarding", and add the port on the computer that you want to be accessible from the phone (detailed instructions here). You'll need to keep open the tab running chrome://inspect/#devices.
In your phone's browser, navigate to localhost:[port_number], and it should display whatever is running on the computer.
This works on Windows and Ubuntu Linux, and should work on Mac as well.
How to Easily access LocalHost in Actual Android Device -> Connect your pc with the android device via USB
Go to Chrome inspection click 'f12' or Control+Shift+C
Chrome Inspection tool
Check the bottom of the chrome inspection tool.
Now go to settings in Remote Device Tab.
Remote Devices Tab
check on "Discover USB Device" option as well as check on "Port Forwarding" option.
Now Click on Add Rules, Enter Any Device Port e.g(4880) and in Local Address Enter the Actual Address of the local host in my case e.g (127.0.0.1:480)
After Adding the Rule go to your android studio -> inside your code URL(http://127.0.0.1:4880). Remember to change the port from 480 -> 4880.
Go to Remote Device Tab in Chrome and Click on your connected Device. Add New URL(127.0.0.1:4880)
Inspect the Android Device Chrome Browser
Check your Actual Device Chrome Browser and start Debugging the code on Actual Android device.
Check for the USB connection type options. You should have one called "Internet pass through". That will let your phone use the same connection as your PC.
I very much liked John's answer, but I'd like to give it with some changes to those that want to test some client//server configuration by running a client TCP on the USB connected Mobile and a server on the local PC.
First it's quite obvious that the 10.0.2.2 won't work because this is a REAL hardware mobile and not a simulator.
So Follow John's instructions:
Unplug all network cables on PC and turn off wifi.
Turn off wifi on the android device
Connect android device to pc via USB
Turn on the "USB Tethering" (USB Modem/ USB Cellular Modem / USB שימוש כמודם סלולרי) in the android menu. (Under networks->more...->Tethering and portable hotspot")
This USB connection will act as a DHCP server for you single PC connection, so it'll assign your PC a dedicated (dynamic) IP in its local USB network. Now all you have to do is tell the client application this IP and port.
Get the IP of your PC (that has been assigned by the USB tether cable.)
(open command prompt and type "ipconfig" then look for
the IP that the USB network adapter has assigned, in Linux its ifconfig or Ubuntu's "Connection information" etc..)
Tell the application to connect to that IP (i.e. 192.168.42.87) with something like (Java - client side):
String serverIP = "192.168.42.87";
int serverPort = 5544;
InetAddress serverAddress = InetAddress.getByName(serverIP);
Socket socket = new Socket(serverAddress, serverPort);
...
Enjoy..
Hello you can access your xampp localhost by
Control panel -->
windows defender firewall -->
Advance setting (on left side) --> Inbound Rules --> New Rule --> Port --> in specific local port write your Apache ports --> next --> next
then you can access your localhost by using local PC IP address:
Zsivics Sanel's answer above work fine for USB Debugging but if you want to access your localhost on device for Wifi ADB you can use command
adb reverse tcp:port tcp:port
and use the link http://localhost:port/ on your android to access the http://localhost:port/ of your pc.
This works for USB Debugging as well :)
The detailed answer with explaination is here.
Connecting android phone via USB cable and accessing http server on the Computer.
Firewall - switch it off, once everything works you can add a rule
under Inbound rules, enable Apache HTTP Server (UDP and TCP) (or whatever HTTP server you're using) Warning - if you switch off the firewall, your computer becomes vulnerable to internet attacks. So switch off internet and disconnect from network first. You don't need to be on the Internet for this to work, as you're connecting two devices on local network.
Plug in the USB cable. If networking window pops up, select Home Network. If it doesn't pop up it's probably set to Public (which won't work), so go to: Control Panel\Network and Internet\Network and Sharing Center (in win7) and set it to Home Network there. It might give you a next screen after you press it to share Pictures, Music... just click cancel on it. On the main screen Home Network will still be active.
You need the Computer's IP, localhost or other aliases don't work. To get the IP of your machine, start the Windows command line shell (press Windows Key + R and type cmd), the black command prompt window should pop up, type: "ipconfig" and hit enter. Now look for
IPv4 Address. . . . . . . . . . . : 192.168.###.###
That's the IP that your phone assigned to your computer
Now you should be done, in the phone's browser, try accessing a test html file from your computer's server it should display fine.
Now that everything is working you'll probably want to enable the firewall and Internet access on your computer. Now try accessing your http server again. It probably won't work. Depending on your setup you might get a popup asking you to add a rule to allow it, but if you don't, just add it yourself. Start the windows firewall and go to Inbound Rules (because it's a server) and add New Rule. Select "Program". Locate the exe of your http server, and in the next screen make sure Allow is selected. Try connecting again, and now it should work. If not it's probably because you selected wrong exe. You can even go more advanced to restrict outside usage (because now everyone on the internet can access it if they have your Internet IP address) To restrict access you can right-click on the new rule you've just created, click Properties, and go to Scope tab and change things there accordingly.
Note for Android developers, now in your android code, you have to use "http://", otherwise it won't work. For example: MyAsyncTask.execute("http://192.168.123.123/test.html")
Part II -- Setting IP to fixed/static.
Now that things work, every time you unplug the cable and plug it back in, your IP will change. And if you are using it somewhere like inside a code, you'll have to update it every time! Solution I've come up with is to set the IP to static.
Having the phone connected and tethered, go back to Network and Sharing Center and click on the Local Area connection "Connections:"
On the next screen select Properties, then highlight IP 4 and press properties there and click "Use the following IP address"
Put Default Gateway and Subnet Mask exactly as it was in the ipconfig, and for the IP Address, only change the last 3 digits to anything from 1 to 255
That IP will be your new fixed/static IP and it will remain the same next time you plug the phone.
Problem I faced maybe it will help some one, I was working long time where my pc and android device connected to the same WiFi network and the android device connected via the IPV4 address of the pc with opened port 8080 trought the fire wall.
ONE DAY :
I installed Genymotion emulator in order to debug UI on different screens.
THANKS to Genymotion/Virtualbox network configurations it ruined my WiFi adapter.
The fix was to reconfigure IPV4/TCP settings on the WiFi netwrok adapter :