AirtestProject / AirtestProject/Poco

注册函数的时候报集合key找不到错误

Abierto
#335 2 comentarios 0 reacciones 1 asignado Reclamado por @dinghongyi Ver en GitHub
Lenguaje dominante
Python
Estrellas
2k
Forks
341
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**(重要!问题分类)**
* 控件识别、树状结构、poco库报错 -> 此仓库

**描述问题bug**
我尝试在PocoManager.cs里面添加自己的方法,然后在脚本里面调用。但是我发现,无论是调用我的方法,还是原本sdk里就注册有的方法,都会在HandleMessage里面走到try-catch的catch。然后报以下错误。尽管我注册的接口有些可以得到结果,但有一个一调用游戏就卡死。目前这个错误实在难以定位,唯一发现异常的就是这个错误。

```
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
01-06 21:49:56.667 6516 6544 E Unity : at System.Collections.Generic.Dictionary`2[System.String,RPCParser+RpcMethod].get_Item (System.String key) [0x000a2] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150
01-06 21:49:56.667 6516 6544 E Unity : at RPCParser.HandleMessage (System.String json) [0x000bc] in D:\unityProjects\TestJNI\Assets\AirtestSDK\Unity3D\PocoManager.cs:306
01-06 21:49:56.667 6516 6544 E Unity : UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
01-06 21:49:56.667 6516 6544 E Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
01-06 21:49:56.667 6516 6544 E Unity : UnityEngine.Logger:Log(LogType, Object)
01-06 21:49:56.667 6516 6544 E Unity : UnityEngine.Debug:LogError(Object)
01-06 21:49:56.667 6516 6544 E Unity : RPCParser:HandleMessage(String) (at D:\unityProjects\TestJNI\Assets\AirtestSDK\Unity3D\PocoManager.cs:314)
01-06 21:49:56.667 6516 6544 E Unity : c__AnonStorey1:<>m__0(String) (at D:\unityProjects\TestJNI\Assets\AirtestSDK\Unity3D\PocoManager.cs:231)
01-06 21:49:56.667 6516 6544 E Unity : System.Collections.Generic.List`1:ForEach(Action`1) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Ge
```

**复现步骤**
脚本代码:
```python
from poco.drivers.unity3d import UnityPoco
from airtest.core.api import *
from poco.utils.simplerpc.utils import sync_wrapper

dev = init_device("Android")
poco = UnityPoco(device=dev)

@sync_wrapper
def call_registered_func(func_name, param=""):
return poco.agent.rpc.call(func_name, param)

ret = call_registered_func("isVRSupported","")
print(ret)
```

**预期效果**
运行`adb logcat | findstr Unity`后,会看到上述日志内容

**相关截图**

![image](https://user-images.githubusercontent.com/50795250/71822599-35132780-30d0-11ea-8610-663b082909a7.png)

**python 版本:** `python3.7.4 64bit`

**poco 版本:** `1.0.79`

**SDK 版本:** `6`

**设备:**
- 型号: [mi 5s plus]
- 系统: [ro.build.version.sdk == 24]

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.