It's getting really frustrating to test any apps at all. I start up the emulator and run the app the first time and it works and immediately starts throwing this in the ADB Logs
DeviceMonitor: Failed to connect to client '2560': EOF
PropertyFetcher: AdbCommandRejectedException getting properties for device emulator-5554: device offline
Logcat displays nothing. I've tried everything to stop this. Killing and starting the adb server does not solve the problem. I have to restart the AVD.
Any help will be appreciated. Thanks
This usually happens because android emulator is just to slow and adb command times out. But you have parameter that you can set to increase this timeouts.
If you are running adb commands through gradle. For example
connnectedCheck
. You can use android plugin DSL to set this parameter as shown blowThis was added in android gradle plugin 1.2.0. Unfortunately it only works if you have multidex enabled. For some reason they forgot to include it for single apk builds. But there is a workaround to handle this. You can just call static method as show below.
If you are running adb commands directly with adb you have an option to set environment variable that will handle this.
Keep in mind that
ADB_INSTALL_TIMEOUT
is set in seconds and not in milliseconds as in gradle DSL.The USB cable connecting the phone to your PC affects the adb devices offline/device status. Try replacing the cable with a known working one.
I faced similar issue, and I run
adb devices
in Terminal and my device is showing offline I restarted the device it started working for me. But you you are frequently getting this issue the restart is not a good solution.
It happened to me with a real device.
Try revoking USB debugging authorizations (from device Settings->Developer options). Then reconnect the device and give the authorization.
Try with this i hope it will help you.
1-adb kill-server
2-adb start-server to restart the adb.
It can be found in your android sdk directory, subfolder plattform-tools.
or
Try to locking and unlocking your emulator by clicking F7 and Check the logcat when you do this.
My advice to anyone using the Emulator is to get off AVD. Get a real device or download Genymotion. The free version gets the Job done.