AdbCommandRejectedException在模拟器中进行测试时获得的属性进行测试、属性、器中、AdbCommandRejectedException

2023-09-06 02:09:19 作者:孤傲的王

它变得很无奈,在所有测试任何应用程序。 我启动模拟器并运行应用程序的第一次,它的工作原理,并立即开始在亚洲开发银行的日志引发此

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中无显示。我用尽了一切办法来阻止这一切。杀戮和启动ADB服务器不解决问题。我不得不重新启动AVD。

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.

任何帮助将AP preciated。谢谢

Any help will be appreciated. Thanks

推荐答案

这通常是因为Android模拟器只是缓慢和亚行命令超时。但是你必须参数,您可以设置增加此超时。

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.

如果您通过摇篮运行的adb命令。例如 connnectedCheck 。您可以使用Android插件DSL这个参数设置如图一击

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
    }
}

这是加入Android的摇篮插件1.2.0。不幸的是,只有当你已经multidex启用工作。出于某种原因,他们忘了,包括它的单APK构建。但是有一个解决办法来处理这​​个问题。您只需调用静态方法,如下图所示。

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)

如果您是直接运行的adb命令与亚洲开发银行,你有一​​个选项来设置环境变量,将处理这个问题。

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

请注意, ADB_INSTALL_TIMEOUT 设置以秒为单位,不以毫秒为单位的摇篮DSL。

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