AirtestProject / AirtestProject/Poco
注册函数的时候报集合key找不到错误
- Dominant language
- Python
- Stars
- 2k
- Forks
- 341
- PR merge metrics
- No merged PRs in 30d
Description
**(重要!问题分类)**
* 控件识别、树状结构、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`后,会看到上述日志内容
**相关截图**

**python 版本:** `python3.7.4 64bit`
**poco 版本:** `1.0.79`
**SDK 版本:** `6`
**设备:**
- 型号: [mi 5s plus]
- 系统: [ro.build.version.sdk == 24]
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.