Android - Run app without USB cable every time

Now a days it's a common problem for Android Developers to run an app every time by connecting with USB cable, Some times it may disconnect your device due to loose connection or USB cable issues, Due to this developer can't able to Debug/Run an app very frequently. So here is the solution for this, now you can run android app without USB cable but you need to connect it at least once to connect with your mobile until and unless you switch off your mobile OR change your mobile network.
You need to connect your device to your computer via USB cable. Make sure USB debugging is working. You can check if it shows up when running adb devices.
Open cmd in ...\AppData\Local\Android\sdk\platform-tools
Step1: Run adb devices
Ex: C:\pathToSDK\platform-tools>adb devices
You can check if it shows up when running adb devices.
Step2: Run adb tcpip 5555
Ex: C:\pathToSDK\platform-tools>adb tcpip 5555
Disconnect your device (remove the USB cable).
Step3: Go to the Settings -> About phone -> Status to view the IP address of your phone.
Step4: Run adb connect <IP address of your device>:5555
Ex: C:\pathToSDK\platform-tools>adb connect 192.168.0.2:5555
Step5: Run adb devices again, you should see your device.
Now you can execute adb commands or use your favourite IDE for android development - wireless!
Now you might ask, what do I have to do when I move into a different work space and change WiFi networks? You do not have to repeat steps 1 to 3 (these set your phone into WiFi-debug mode). You do have to connect to your phone again by executing steps 4 to 5.
Unfortunately, the android phones lose the WiFi-debug mode when restarting. Thus, if your battery died, you have to start over. Otherwise, if you keep an eye on your battery and do not restart your phone, you can live without a cable for weeks!
Happy wireless coding!
You can also see my answer in Stack Over Flow: https://stackoverflow.com/a/44442586/2462531
UPDATE:
If you set C:\pathToSDK\platform-tools this path in Environment variables then there is no need to repeat all steps, you can simply use only Step 4 that's it, it will connect to your device.
To set path : My Computer-> Right click--> properties -> Advanced system settings -> Environment variables -> edit path in System variables -> paste the platform-tools path in variable value -> Ok -> Ok -> Ok

Comments

Post a Comment

Thank you will get back to you soon.

Popular posts from this blog

How to create a website as android app using web view in Kotlin language.

Android Singleton class to make it use of globally in application