Android Studio
SDK
- 使用国内源
- 使用代理
Android Update Site
https://dl.google.com/android/repository/repository2-3.xml
curl https://dl.google.com/android/repository/repository2-3.xml
curl -i https://dl.google.com/android/repository/android-22_r02.zip
环境变量
export ANDROID_HOME=/Users/seveniruby/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH
Android命令行工具文档
https://developer.android.com/studio/command-line?hl=zh-cn
Emulator
- intel芯片 x86指令集 pc win+intel mac+intel mac+m1
- arm芯片 arm指令集 arm
- app exe apk lib/armeabi-v7a/
App
- Java Kotlin 模拟器通用
- Native 使用了so,如果lib包含arm,说明支持arm模拟器
- Native 使用了so,如果lib包含x86,说明支持x86模拟器
- mac m1 本身有一些环境判断的bug,可能会导致arm指令集的应用无法运行
Adb
adb基本概念
#adb client 用来执行一些指令
hogwarts: ~ seveniruby$ adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
emulator-5554 offline
#adb server 维持与手机的连接,usb或者tcp/ip
hogwarts: ~ seveniruby$ ps -ef | grep adb
503 45969 1 0 3:05PM ?? 0:00.01 adb -L tcp:5037 fork-server server --reply-fd 4
#adbd 维持与pc等外部连接的通讯 执行指令
hogwarts: ~ seveniruby$ adb shell "ps | grep adb"
root 902 1 15012 760 poll_sched 00004383b0 S /sbin/adbd
adb通讯拦截
- 定位问题
- mock
mitmproxy代理工具
通讯中转
adb -P 8080 devices
使用mitmproxy监听通讯
hogwarts: ~ seveniruby$ mitmdump -m reverse:127.0.0.1:5037 --flow-detail 4
Proxy server listening at *:8080
127.0.0.1:57419: client connect
127.0.0.1:57419: server connect 127.0.0.1:5037
127.0.0.1:57419 -> tcp -> 127.0.0.1:5037
000chost:version
127.0.0.1:57419 <- tcp <- 127.0.0.1:5037
OKAY00040029
127.0.0.1:57419: client disconnect
127.0.0.1:57419: server disconnect 127.0.0.1:5037
127.0.0.1:57421: client connect
127.0.0.1:57421: server connect 127.0.0.1:5037
127.0.0.1:57421 -> tcp -> 127.0.0.1:5037
000chost:devices
127.0.0.1:57421 <- tcp <- 127.0.0.1:5037
OKAY0015emulator-5554 device
127.0.0.1:57421: client disconnect
127.0.0.1:57421: server disconnect 127.0.0.1:5037
Monkey
https://developer.android.com/studio/test/other-testing-tools/monkey?hl=zh-cn
Appium
- Appium https://github.com/appium/appium
- Appium Server GUI https://github.com/appium/appium-desktop/releases/
- Appium Inspector https://github.com/appium/appium-inspector/releases
npm install -g appium
Appium Inspector
[
{
"key": "elementId",
"value": "00000000-0000-0001-7fff-ffff0000001c",
"name": "elementId"
},
{
"key": "index",
"value": "2",
"name": "index"
},
{
"key": "package",
"value": "com.android.calculator2",
"name": "package"
},
{
"key": "class",
"value": "android.widget.Button",
"name": "class"
},
{
"key": "text",
"value": "9",
"name": "text"
},
{
"key": "resource-id",
"value": "com.android.calculator2:id/digit_9",
"name": "resource-id"
},
{
"key": "checkable",
"value": "false",
"name": "checkable"
},
{
"key": "checked",
"value": "false",
"name": "checked"
},
{
"key": "clickable",
"value": "true",
"name": "clickable"
},
{
"key": "enabled",
"value": "true",
"name": "enabled"
},
{
"key": "focusable",
"value": "true",
"name": "focusable"
},
{
"key": "focused",
"value": "false",
"name": "focused"
},
{
"key": "long-clickable",
"value": "false",
"name": "long-clickable"
},
{
"key": "password",
"value": "false",
"name": "password"
},
{
"key": "scrollable",
"value": "false",
"name": "scrollable"
},
{
"key": "selected",
"value": "false",
"name": "selected"
},
{
"key": "bounds",
"value": "[527,672][747,920]",
"name": "bounds"
},
{
"key": "displayed",
"value": "true",
"name": "displayed"
}
]
[
{
"key": "elementId",
"value": "00000000-0000-0001-7fff-ffff00000001",
"name": "elementId"
},
{
"key": "index",
"value": "0",
"name": "index"
},
{
"key": "package",
"value": "com.android.calculator2",
"name": "package"
},
{
"key": "class",
"value": "android.widget.EditText",
"name": "class"
},
{
"key": "text",
"value": "",
"name": "text"
},
{
"key": "resource-id",
"value": "com.android.calculator2:id/formula",
"name": "resource-id"
},
{
"key": "checkable",
"value": "false",
"name": "checkable"
},
{
"key": "checked",
"value": "false",
"name": "checked"
},
{
"key": "clickable",
"value": "true",
"name": "clickable"
},
{
"key": "enabled",
"value": "true",
"name": "enabled"
},
{
"key": "focusable",
"value": "true",
"name": "focusable"
},
{
"key": "focused",
"value": "true",
"name": "focused"
},
{
"key": "long-clickable",
"value": "true",
"name": "long-clickable"
},
{
"key": "password",
"value": "false",
"name": "password"
},
{
"key": "scrollable",
"value": "false",
"name": "scrollable"
},
{
"key": "selected",
"value": "false",
"name": "selected"
},
{
"key": "bounds",
"value": "[0,63][1080,372]",
"name": "bounds"
},
{
"key": "displayed",
"value": "true",
"name": "displayed"
}
]
Appium启动Log
作业
- 分析Appium Log
- 提取所有的Adb执行命令
- 对每个命令进行说明
- 发帖到论坛
#作用说明注释
adb -P 5037 -s emulator-5554 shell dumpsys window
#作用说明注释
adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server