I am using Genymotion Emulator with Nexus s and 4.2.2.
Previously i used regular AVD that we can create using Eclipse provided by ANDROID SDK.
In regular AVD we can enable/disable data packet access to internet by using
Settings->Wireless&Networks->Data Enabled
Or by pressing F8 key but i am unable to found it in Genymotion emulator.
Where i can find it?
You cannot do that on Genymotion.
If you want to test what your application will do without internet access, you can unplug your ethernet cable or switch off your Wi-Fi.
It's not the same but could still help to test your app.
I hade this problem.
If you disable the internet and try to debug your app, the app will not be able to connect to vs code debug server.
This what you should do.
1- in your emulator, click Debug/settings and change the ip:port to the following localhost:your port eg 5555
2- disable the wifi and your app will start without internet but still able to connect to vs code
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 searched on how to get an Internet connection from my emulator in Android Studio and it was suggested I start up the emulator from the command line as follows: emulator -avd Pixel_3a_XL_API_29 -dns-server 8.8.8.8. This indeed has provided an Internet connection when I do from the command line, after adb shell, then run-as com.example.myapplication, then ping abcnews.go.com. this returns packets from the server "...r.cloudfront.net". Looking up this server, it appears to be for Amazon AWS, and is "free", up to some data limit I haven't looked up yet. This is OK short-term, but I would prefer to use my home wifi rather than go thru a different server. What's the best way to have my Android Studio emulator be able to connect to the Internet via my home wifi? (do I need a plugin?) TIA, Steve
First of all, emulator below API 25 doesn't support wifi.
Second, you can't connect the emulator directly to your WiFi.
The WiFi in the emulator provides a virtual hotspot to which the emulator automatically connects.
So, best practice would be that you connect your PC to your home WiFi and then run the emulator on your PC.
I am developing an app for a new Android device (on all other I've never had this issue).
It's running 4.2.2
I have enabled developer mode and allowed usb debugging (I receive the status notification that usb debugging enabled)
However, in chrome://inspect the screen keeps alternating between the below two messages, seems it can't make up it's mind!
ratech72_wet_rlk_lca #0123456789ABCDEF
Offline #00180123456789ABCDEF Pending authentication: please accept debugging session on the device.
I've tried unplugging and restarting everything to no avail
When I plug in the device I see the following status messages on the device systray, in this order
Connected as USB Storage
USB Debugging Connected
USB Connected
How can I access chrome inspect on this device? I am using logcat for now but it's far less powerful than chrome dev tools.
This is a known issue.
The answer in the link (changing USB mode from MTP to PTP) did work for me for some time, however others have had less success, and my setup has now regressed to the erratic connection you are seeing.
Personally, I just try to play quick draw and click on the device when it's listed before it disconnects again, which after a bit of practice doesn't take too long, and once you've done that, the actual inspect tools don't have the same erratic connect/disconnect problem so you should be fine until you physically disconnect the device.
This should be resolved in a future version of Chrome.
I know this is an old question, but nonetheless, this is what helped me:
while in Chrome chrome://inspect/#devices page is opened
turn off USB Debugging,
turn on USB Debugging again
The phone will ask me if I trust the connection...
You will need to check out the Facebook Stetho debugging tool:
http://facebook.github.io/stetho/
It is pretty easy to get up and running. And it works well if you are using OkHttp developed by square to debug networking tools.
add to gradle:
dependencies {
implementation 'com.facebook.stetho:stetho:1.5.0'
}
then in your application class:
Stetho.initializeWithDefaults(this);
and then go to chrome://inspect in your browser and you should see your device
This is what I did in Android 10 (Oneplus 7t pro), to make it to work(in addition to #gordan.sikic answer).
While in Chrome, keep chrome://inspect/#devices page opened
Click and accept, Android Phone -> Settings -> Developer Options -> Revoke USB debugging authorizations
Turn off USB debugging
Turn on USB debugging, accept Allow USB debugging.
Then you 'll see Always allow from this computer Notification
In the virtual Device Manager I selected Wipe Data from the Actions.
Then I started the virtual device.
Then I ran the app and it worked in the emulator.
I found that sometimes I am unable to inspect Android device via Chrome://inspect because I'm in some other country and connecting to US server on both the mobile device and the dev machine via VPN fixes the problem.
I would like to simulate some network problems with the emulator. I know that pressing f8 I can disable the network but, as a result, I lost the connection with eclipse, the adb and the debug session!
Furthermore, I can not test the case where a server may not work well while the network is ok, or other similar network problems.
Install GenyMotion
Setup a VM of a tablet
Use this via Eclipse
Then in the VM
Settings
WiFi OFF
Works a dream , just tried it
Phil
You can use telnet to get access to the Android Console within the emulator, and from there you can affect speed and latency of the emulated network connection.
I am playing some Android development and am trying to debug the application via Eclipse on my phone (HTC) with internet access by means of USB tethering because I can't get 3g connection where I am developing and there is no wifi.
I can run the app ok on the phone, but as it requires HTC Sync to be running I am unable to use the internet connection from my computer, is there a way?
Usually android needs the adb to debug devices and afaik adb needs USB connection.
Other ways would be ACRA and BugSense
You can always try to use an emulator: see here
You can also use aLogCat on your phone to have access to debugging information directly on the phone, after installing a testversion of your app.