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/