<p cms-style="font-L strong-Bold"> 📱 在 Android 手机上运行 OpenClaw 完整教程</p><p cms-style="font-L strong-Bold"> 🧪 实验环境</p><div cms-style="font-L scroll"><div cms-style="font-L minWidth"><div cms-style="table"><thead cms-style="thead"><tr cms-style="tr"><th cms-style="th"><p cms-style="font-L strong-Bold isIntable "> 项目</p></th><th cms-style="th"><p cms-style="font-L strong-Bold isIntable "> 配置</p></th></tr></thead><tbody cms-style="tbody"><tr cms-style="tr"><td cms-style="td">手机型号</td><td cms-style="td"><p cms-style="font-L isIntable "> Redmi K50 Pro</p></td></tr><tr cms-style="tr"><td cms-style="td">运行内存</td><td cms-style="td"><p cms-style="font-L isIntable "> 8GB</p></td></tr><tr cms-style="tr"><td cms-style="td">OpenClaw 版本</td><td cms-style="td"><p cms-style="font-L isIntable "> v2.6-3(最新版)</p></td></tr></tbody></div></div></div><p cms-style="font-L strong-Bold"> <font cms-style="font-L strong-Bold">🧪 </font><font cms-style="font-L strong-Bold">对接飞书效果</font></p><div class="img_wrapper"><img src="https://k.sinaimg.cn/n/sinakds/7/w515h1092//9907-45d5735cc3c0f15c7b1a6437fa9911e3.png/w700d1q75cms.jpg?by=cms_fixed_width" w="515" h="1092" wh="0.47"/></div><p cms-style="font-L strong-Bold"> <font cms-style="font-L strong-Bold">🧪 </font><font cms-style="font-L strong-Bold">安装完成效果</font></p><div class="img_wrapper"><img src="https://k.sinaimg.cn/n/sinakds/763/w537h1026//9ec6-cdee5c78b64119d551b66f.png/w700d1q75cms.jpg?by=cms_fixed_width" w="537" h="1026" wh="0.52"/></div><p cms-style="font-L strong-Bold"> 📦 准备工作</p><p cms-style="font-L strong-Bold"> 需要安装的应用</p><ol cms-style="ol"><li cms-style="li"><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">Termux</font></font><p cms-style="font-L"> - 安卓端的 Linux 终端环境</p></li><li cms-style="li"><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">Termux:API</font></font><p cms-style="font-L"> - 用于控制安卓硬件的扩展插件</p><p cms-style="font-L"> - 如 termux-battery-status 查看电池状态</p></li></ol><p cms-style="font-L strong-Bold"> 🔽 下载方式</p><p cms-style="font-L"> <font cms-style="font-L">推荐通过 </font><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">F-Droid</font></font><font cms-style="font-L"> 应用商店安装:</font></p><ol cms-style="ol"><li cms-style="li"><p cms-style="font-L"> 先下载安装 F-Droid</p></li><li cms-style="li"><p cms-style="font-L"> 在 F-Droid 中搜索并安装上述两款应用</p></li></ol><blockquote cms-style="blockquote"><p cms-style="font-L"> <font cms-style="font-L">💡 </font><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">提示</font></font><font cms-style="font-L">:F-Droid 是开源应用商店,比直接下载 APK 更安全可靠</font></p></blockquote><p cms-style="font-L strong-Bold"> 🚀 安装步骤详解</p><p cms-style="font-L strong-Bold"> 步骤一:配置 Termux 远程访问</p><p cms-style="font-L"> 在手机上打开 Termux,依次执行以下命令:</p><p> # 安装身份验证工具pkg install termux-auth# 设置登录密码(会提示输入两次)passwd# 启动 SSH 服务sshd</p><p cms-style="font-L"> <font cms-style="font-L">✅ </font><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">完成后</font></font><font cms-style="font-L">:手机已开启 SSH 服务,端口为 </font><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">8022</font></font></p><p cms-style="font-L strong-Bold"> 步骤二:电脑端连接手机</p><p cms-style="font-L"> <font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">推荐方案</font></font><font cms-style="font-L">:电脑开启热点,手机连接,确保在同一局域网</font></p><p> # 连接命令(IP 地址请替换为你手机的实际 IP)ssh -p 8022 192.168.137.219# 输入步骤一中设置的密码即可登录</p><p cms-style="font-L strong-Bold"> 步骤三:环境初始化</p><p cms-style="font-L"> 连接成功后,在 Termux 中执行:</p><p> # 申请存储权限(会弹出授权窗口)termux-setup-storage# 更换软件源(选择清华/中科大镜像,速度更快)termux-change-repo# 安装必要依赖pkg install vim git nodejs-lts python make clang build-essential openssh termux-api -y</p><p cms-style="font-L strong-Bold"> 步骤四:安装 OpenClaw</p><p> npm install -g openclaw --verbose --no-optional</p><p cms-style="font-L strong-Bold"> 步骤五:修复路径问题(关键步骤)</p><p cms-style="font-L"> <font cms-style="font-L">⚠️ </font><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">直接运行会报错</font></font><font cms-style="font-L">,因为 Termux 不支持系统 </font><font cms-style="font-L strong-Bold"><font cms-style="font-L strong-Bold">/tmp</font></font><font cms-style="font-L"> 目录,需要执行以下修复脚本:</font></p><p> # ========== 第一步:创建合法的临时目录 ==========mkdir -p $PREFIX/tmp/openclaw# ========== 第二步:批量替换源码中的非法路径 ==========sed -i "s|/tmp/openclaw|$PREFIX/tmp/openclaw|g" $(npm root -g)/openclaw/dist/*.js# ========== 第三步:永久配置环境变量 ==========# 设置 Node.js 临时目录为 Termux 合法路径echo "export TMPDIR=$PREFIX/tmp" >> ~/.bashrc# 强制 Node.js 使用 IPv4 解析(解决 DNS 报错)echo "export NODE_OPTIONS='--dns-result-order=ipv4first'" >> ~/.bashrc# ========== 第四步:用 Node.js 脚本深度修复路径 ==========node -e "const fs = require('fs');const path = require('path');const openclawDir = path.join(process.env.PREFIX, 'lib/node_modules/openclaw/dist');fs.readdirSync(openclawDir).forEach(file => });console.log('\n✅ OpenClaw 路径修复全部完成!');"# ========== 第五步:让环境变量立刻生效 ==========source ~/.bashrcecho -e "\n🎉 所有修复已完成!现在可以正常使用 openclaw 命令了。"# 安装守护进程openclaw onboard --install-daemon</p><p cms-style="font-L strong-Bold"> 步骤六:获取 Token 并启动服务</p><p> # 获取访问 token(会显示 URL 和 token)openclaw dashboard --no-open# 启动网关服务(保持运行)openclaw gateway --force</p><p cms-style="font-L strong-Bold"> 步骤七:配置 API 密钥</p><p cms-style="font-L strong-Bold"> 方式 A:使用文件管理器(推荐)</p><ol cms-style="ol"><li cms-style="li"><font cms-style="font-L">用安卓自带文件管理器替换:</font><p> /data/data/com.termux/files/home/.openclaw/openclaw.json</p></li></ol><p cms-style="font-L strong-Bold"> 方式 B:使用 SFTP 传输</p><p> # 通过 SFTP 连接(使用 xftp 等工具)sftp://192.168.137.219:8022# 上传路径:/data/data/com.termux/files/home/.openclaw/openclaw.json</p><p cms-style="font-L strong-Bold"> ✅ 配置完成!</p><p cms-style="font-L"> 替换 JSON 配置文件后,OpenClaw 就可以正常运行了!</p><p cms-style="font-L strong-Bold"> ⚠️ 重要注意事项</p><div cms-style="font-L scroll"><div cms-style="font-L minWidth"><div cms-style="table"><thead cms-style="thead"><tr cms-style="tr"><th cms-style="th"><p cms-style="font-L strong-Bold isIntable "> 注意点</p></th><th cms-style="th"><p cms-style="font-L strong-Bold isIntable "> 说明</p></th></tr></thead><tbody cms-style="tbody"><tr cms-style="tr"><td cms-style="td">插件问题</td><td cms-style="td"><p cms-style="font-L isIntable "> v2.6-3 已内置飞书插件,无需再执行 npm install 安装插件</p></td></tr><tr cms-style="tr"><td cms-style="td">网关服务</td><td cms-style="td"><p cms-style="font-L isIntable "> 不支持 gateway install 命令,使用 gateway --force 即可,不影响正常使用</p></td></tr><tr cms-style="tr"><td cms-style="td">保持运行</td><td cms-style="td"><p cms-style="font-L isIntable "> 启动 gateway 后不要关闭 Termux,否则服务会停止</p></td></tr><tr cms-style="tr"><td cms-style="td">后台保活</td><td cms-style="td"><p cms-style="font-L isIntable "> 建议在手机设置中将 Termux 设为「允许后台运行」和「电池优化白名单」</p></td></tr></tbody></div></div></div><p cms-style="font-L strong-Bold"> 🎯 快速检查清单</p><ul cms-style="ul"><li cms-style="li"><p cms-style="font-L"> 已安装 Termux 和 Termux:API</p></li><li cms-style="li"><p cms-style="font-L"> 已完成 SSH 配置并测试连接</p></li><li cms-style="li"><p cms-style="font-L"> 已执行路径修复脚本且无报错</p></li><li cms-style="li"><p cms-style="font-L"> 已获取 token 并记录</p></li><li cms-style="li"><p cms-style="font-L"> 已替换 openclaw.json 配置文件</p></li><li cms-style="li"><p cms-style="font-L"> 网关服务已正常启动</p></li></ul> <div style="font-size: 0px; height: 0px; clear: both;"></div>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/215109.html