--- tags: Android --- # Android ADB Install an APK on Multiple Devices Over Wi-Fi > [name=Mr. Akashic] [time=Tue, Mar 23, 2021] ## Prerequisite 1. [Download SDK Platform-Tools](https://developer.android.com/studio/releases/platform-tools) 2. Set up ADB environment variable on Windows 10 {%slideshare AkashaC1/set-an-environment-variable-in-windows-10-245045235 %} ## Implementation ### Step 1. 將Android設備和電腦連上共同的Wi-Fi :::info :warning: **注意:** 並非所有的Wi-Fi AP都支援ADB(Android Debug Bridge),需要設定AP的防火牆。 ::: ### Step 2. 使用USB線連接Android設備和電腦 只有第一次使用Wi-Fi安裝APK的設備才需要進行步驟二的動作,否則前往Step 5。 :::info :warning: **注意:** 如果要連接到Wear OS的穿戴式設備請關閉手機上與該穿戴式設備配對的藍牙。 ::: ### Step 3. 使用下列指令,設定Android設備監聽port 5555 ```bash= adb -d tcpip 5555 ``` <span class="dark_orange">-d</span>表示該指令的作用對象是實體設備,不是模擬器。 ### Step 4. 拔掉Android設備和電腦連接的USB線 ### Step 5. 找出Android設備的IP address ### Step 6. 使用下列指令,透過IP address連線Android設備 ```bash= adb connect device_ip_address:port ``` ### Step 7. 使用下列指令,確認Android設備連接成功 ```bash= adb devices ``` ``` Output List of devices attached 192.168.0.117:5555 device 192.168.0.146:5556 device ``` ### Step 8. 使用下列指令,安裝APK到指定的Android設備 ```bash= adb -s 192.168.0.117:5555 install robot.apk ``` <span class="dark_orange">-s</span>表示要指定設備的serial number。 ## Building Automation Script 將上述實作步驟整理成一個自動化安裝apk的shell腳本。使用該腳本前,請先完成上述實作Step 1~4。 該腳本應用的情境在一次幫多台Android系統的機器人和平板安裝各自的app。 {%gist awlchang/d599a9ee60cdc0b801b4a884d57be42a %} ## Operating Environment * Windows 10 * Android 10 或更早期的版本 * Local area network  ## Acknowledgements 1. [Android Debug Bridge(adb)](https://developer.android.com/studio/command-line/adb) 2. [SDK Platform Tools release notes](https://developer.android.com/studio/releases/platform-tools) 3. [Android ADB原理及常用命令](https://iter01.com/578407.html) <style> .dark_orange { color: #FF8C00; background:#F6F6F6; border-radius:4px; padding-right:6px; padding-left:6px; } .sub_title { font-size: 25px; } .blockquote { background:#F6F6F6; } </style>
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.