android机器人 模拟 踩坑过程

使用框架:RoDroid+lua(源码在aliyun-git)

android安装git和openssh(Termux方案):
安装教程:https://www.techrepublic.com/article/how-to-install-git-on-android/
termux官网:https://termux.com/ (没有直接的下载链接,需要通过F-Droid[国外的应用市场,下载会比较慢])
下载F-Droid:https://f-droid.org/packages/com.termux/
手机安装F-Droid后,搜索Termux并安装:未FQ搜索和安装都比较慢
安装后,先切换源再执行其他命令:https://mirrors.tuna.tsinghua.edu.cn/help/termux/

pc连接android(通过termux):
通过住账号/密码连接:https://www.cnblogs.com/zeng-qh/p/15491459.html
https://blog.csdn.net/yangwangnndd/article/details/100728744(通过这个实现的远程执行命令)
公钥无密连接:https://blog.csdn.net/qq_21808961/article/details/102859280

远程执行命令:
https://www.cnblogs.com/softidea/p/6855045.html

输入   sshd   # 开启ssh 

查看手机端ip :ifconfig # 查询本地局域网ip

手机上termux查看用户名: whoami 


代码快捷同步命令:
git add -A && git commit -m "测试" && git push && ssh -p 8022 u0_a237@192.168.7.153 "cd ~/storage/shared/roscript; git pull"


坑:需要开启sshd服务;需要解决ssh免密登录的问题(可参考:https://www.cnblogs.com/Denny_Yang/p/14380787.html)

定位android元素path(通过appnium实现):
安装使用说明:https://www.cnblogs.com/RuiRuia/articles/12199702.html
server和解析器已分开,要分别安装:
appium-desktop下载地址:https://github.com/appium/appium-desktop/releases
appium-inspector下载地址:https://github.com/appium/appium-inspector/releases

appium-inspector配置和使用:https://www.jianshu.com/p/0a19409c0d37
查看deviceName: cmd执行:> adb devices
查看当前运营的app包和activity(appPackage&appActivity): cmd执行:> adb shell dumpsys window | findstr mCurrentFocus
查看安卓系统版本(platformVersion):cmd执行:> adb shell getprop ro.build.version.release

定位技巧:https://www.cnblogs.com/tuxiaomeng/p/10442514.html

定位android元素path(通过weditor[未实践]):
https://www.cnblogs.com/yoyoketang/p/11204534.html
https://github.com/openatx/weditor

解析动态页面上的元素很慢(10s以上),并提示: Could not detect idle state
找到超时时间的配置,修改为1s(通过id解析恢复到1-2s,通过text遍历的解析仍然需要10s[之前要20s])


退出所有app:
https://blog.csdn.net/ZoeyZY/article/details/100559377


python模拟程序(封装好的,都不用管java代码):
https://github.com/openatx/uiautomator2

原文地址:https://www.cnblogs.com/Denny_Yang/p/15660214.html