Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdbCommandRejectedException getting properties when testing on emulator

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

like image 424
Michael Obi Avatar asked Mar 02 '15 18:03

Michael Obi


People also ask

How do I know if my emulator is online?

The way that Android detects emulators is by scanning ports starting at port 5555. The number you see in the adb devices list (in your case 5554) will be one less than the port that adb is finding open. You probably have a process running that is listening on port 5555.

How do I run adb emulator?

Installing an app Build and package your app into an APK as described in Build and Run Your App. Start the emulator from the command line as described in the previous section, using any startup options necessary. Install your app using adb. Run and test your app on the emulator.


1 Answers

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 blow

android {
    adbOptions {
        timeOutInMs 60000 // set timeout to 1 minute
    }
}

This 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.

com.android.ddmlib.DdmPreferences.setTimeOut(60000)

If you are running adb commands directly with adb you have an option to set environment variable that will handle this.

export ADB_INSTALL_TIMEOUT=5

Keep in mind that ADB_INSTALL_TIMEOUT is set in seconds and not in milliseconds as in gradle DSL.

like image 123
Blaz Avatar answered Feb 09 '23 02:02

Blaz