AdbCommandRejectedException 在模拟器上测试时获取属性 [英] AdbCommandRejectedException getting properties when testing on emulator

查看:24
本文介绍了AdbCommandRejectedException 在模拟器上测试时获取属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

测试任何应用程序都变得非常令人沮丧.我第一次启动模拟器并运行该应用程序,它可以工作并立即开始将其放入 ADB 日志中

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.

任何帮助将不胜感激.谢谢

Any help will be appreciated. Thanks

推荐答案

这通常是因为 android 模拟器运行缓慢和 adb 命令超时.但是您可以设置参数来增加此超时.

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.

如果您通过 gradle 运行 adb 命令.例如connectedCheck.你可以使用android plugin 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 gradle 插件 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 运行 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 以秒为单位设置,而不是在 gradle DSL 中以毫秒为单位.

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

这篇关于AdbCommandRejectedException 在模拟器上测试时获取属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆