iOS
simulator
Android
# Android Studio 内新建需要的设备
# 新建设备的系统选择 Google APIs 版本,可root;否则: adbd cannot run as root in production builds
# 关闭 Android Studio
cd ~/Library/Android/sdk/emulator/
# 运行以下命令来列出可用的模拟器:
./emulator -list-avds
# 选择你想要启动的模拟器,然后运行:
# 留意 -writable-system ,后续修改host需要可写系统目录的权限
./emulator -avd P8 -writable-system
cd ~/Library/Android/sdk/platform-tools
./adb
export PATH=$PATH:~/Library/Android/sdk/platform-tools
共用宿主机的网络,不包括 host
# 修改host
adb root
adb remount
adb push /etc/hosts /etc/hosts
# adb 映射 宿主机端口 和 模拟器端口
adb reverse tcp:4000 tcp:4000
# 列出所有连接的设备及其序列号:
adb devices
# 使用 -s 选项指定设备的序列号:
adb -s <设备序列号> reverse tcp:4000 tcp:4000
adb -s emulator-5554 reverse tcp:4000 tcp:4000
安装应用
Apk 拖拽到模拟器
宿主机 Chrome 调试
# 直接执行
adb shell ls
# 或者 进入交互式shell执行
adb shell
# 查看ip
ip addr show eth0
# 重启
adb reboot
netstat -rn
ip addr show eth0
10.0.2.2
adb push /etc/hosts /etc/hosts
活动监视器中强制退出adb
模拟器内切换到chrome,再切回app
Https
cd ~/Library/Application\\ Support/mkcert
openssl x509 -inform PEM -in rootCA.pem -outform DER -out rootCA.der
# adb push rootCA.der /sdcard/
# 安装为系统证书
# openssl x509 -inform PEM -in rootCA.pem -out rootCA.crt
openssl x509 -subject_hash_old -in rootCA.pem
adb root
adb remount
adb push rootCA.crt /system/etc/security/cacerts/
# 直接赋权
adb shell chmod 644 /system/etc/security/cacerts/rootCA.crt
# 或者 进入交互式shell赋权
adb shell
su
chmod 644 /system/etc/security/cacerts/rootCA.crt
adb reboot
Host
https://jeroenmols.com/blog/2023/01/25/development-server-emulator/
https://nickhoo555.feishu.cn/space/api/box/stream/download/asynccode/?code=YzIzZTdlYjAxMjJlY2JiNGE0YjdjYmVlNWUyY2FkMzBfbGJ3OVN1U3hGZmhWN2VaM1hiUnZjOEk2clA3aHdjenBfVG9rZW46RU9qQ2JDVzhob3MyWWF4dnhxZWN5aWw4bnRlXzE3Mjk1Nzc0NDE6MTcyOTU4MTA0MV9WNA
https://nickhoo555.feishu.cn/space/api/box/stream/download/asynccode/?code=OGFjN2RlNjE0MGVlZjNhZWI5YmE4MGE4YWQ5Nzg3YTNfT3FRY296elNidGNqR0hINFQ1bzZXdk1hMkdqZHR2TkZfVG9rZW46REduUWIyQmdDb08xZ3p4Nmw5eGNjUEd0bklmXzE3Mjk1Nzc0NDE6MTcyOTU4MTA0MV9WNA
https://nickhoo555.feishu.cn/space/api/box/stream/download/asynccode/?code=MzJhZGVhNTM5MWMzYmYyN2NlNTJmYmIzMDkzMThhZWVfS0pPU1JDMlk4M2lXNTlTbnFxZWF6bldyUkRnakU2ck1fVG9rZW46UWVRYWJJNEVkb3hLd2F4Y1hwMGNaM05MbjZiXzE3Mjk1Nzc0NDE6MTcyOTU4MTA0MV9WNA
https://nickhoo555.feishu.cn/space/api/box/stream/download/asynccode/?code=ZWJlOGIxMjk1ZThhYzU4MWM4OThkNGY4NDczYjU2Y2ZfUEVhcTdFVWhvU3U0c1o4eUEzVFQwVGpMb3lJRzEyd0NfVG9rZW46QWdBZGJvN3Jnb3hBanp4UUdlOGNEbTk4bmFoXzE3Mjk1Nzc0NDE6MTcyOTU4MTA0MV9WNA
https://nickhoo555.feishu.cn/space/api/box/stream/download/asynccode/?code=NjA2NjJhMGQ1ODdjYTBlNjQ2NTI1OTMxNWIyYzA2MDZfSVJ0andsQ0h0VG16QVhmY1hZQkJwckxpQmVpN1lxZkdfVG9rZW46UUlOSGJVM3lkb29JNkR4NjJmZmMyT0FnbjMwXzE3Mjk1Nzc0NDE6MTcyOTU4MTA0MV9WNA
https://nickhoo555.feishu.cn/space/api/box/stream/download/asynccode/?code=OGFiZjVhZDU2YzM3MzExZmMzMGY2NjIxOGEzYTY1ZTVfTXBVUnBlMmNISW9qYmxWb1RlSnA0YjBmNVg4OFdyZkJfVG9rZW46RkNwVWJESnlMb2JjNmt4cnFHRmNjS2o4bnlnXzE3Mjk1Nzc0NDE6MTcyOTU4MTA0MV9WNA