Use ADB to Push Files / Install APKs and Control Android Devices with Scrcpy

Cover.jpeg
Cover.jpeg

An­droid De­bug Bridge (ADB) is a ver­sa­tile com­mand-line tool that al­lows users to in­ter­act with An­droid de­vices.

scrcpy is a pow­er­ful tool that al­lows users to con­trol and mir­ror An­droid de­vice's screen on com­puter.

Prerequisites:

  1. Enable Developer Options on Android device:

2025-02-05_Developer.jpg
2025-02-05_Developer.jpg

    • Go to Settings > About phone.
    • Tap Build number 7 times until you see a message saying "You are now a developer!"
    1. Enable USB Debugging:

    2025-02-05_USB-Debugging.jpg
    2025-02-05_USB-Debugging.jpg

    • Go to Settings > System > Developer options.
    • Enable USB debugging.
    1. Install ADB on computer:
    • Windows Platform (via Chocolatey)

      Open an elevated Command Prompt (Run as Ad­min­is­tra­tor).
    @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

    Close and re­open the Com­mand Prompt to en­sure the in­stal­la­tion is rec­og­nized.

    choco install adb
    adb --version
    • Linux Platform (Ubuntu/Debian)
    sudo apt install adb -y
    adb version

    Part 1: Pushing Files to an Android Device Using ADB

    1. Connect Android device to computer via USB.

      • Make sure the de­vice is rec­og­nized by run­ning:

        adb devices
      • If device is listed, you're ready to proceed. If not, check USB connection and drivers.
    2. Push File(s) to the device:

      • Use the adb push com­mand to copy the file to a di­rec­tory on de­vice. For ex­am­ple:

        adb push path/to/app.apk /sdcard/

    2025-02-06_100519.jpg
    2025-02-06_100519.jpg

    adb push ./Cover.jpeg /storage/emulated/0/Backup/
    This com­mand copies Cover.jpeg to the /storage/emulated/0/Backup/ di­rec­tory on de­vice.
    1. Install the APK:

      • Use the adb install com­mand to in­stall the APK di­rectly:

        adb install path/to/app.apk
      • If the APK is al­ready on the de­vice (e.g., in /sdcard/), you can in­stall it us­ing:

        adb shell pm install /sdcard/app.apk
    2. Verify the installation:

      • Check if the app is in­stalled by search­ing for it on de­vice or us­ing:

        adb shell pm list packages | grep package.name

    Notes:

    • If you en­counter per­mis­sion is­sues, you may need to re­mount the sys­tem par­ti­tion as read-write (re­quires root ac­cess):

      adb root
      adb remount
    • For system apps, you may need to push the APK to /system/app/ or /system/priv-app/ and set the correct permissions.

    Example:

    • Push the APK to the device
    adb push app.apk /sdcard/
    • Install the APK
    adb install /sdcard/app.apk
    • Alternatively, install directly from computer
    adb install path/to/app.apk

    That's it! You've suc­cess­fully pushed and in­stalled an APK us­ing ADB.


    Part 2: Using Scrcpy to Mirror and Control Android Device


    Prerequisites

    1. Enable USB Debugging on Android device:

    2025-02-05_Developer.jpg
    2025-02-05_Developer.jpg

    • Go to Settings > About phone > Tap Build number 7 times to enable Developer Options.

    2025-02-05_USB-Debugging.jpg
    2025-02-05_USB-Debugging.jpg

    • Go to Settings > System > Developer options > Enable USB debugging (also with Wireless debugging).
    1. Install ADB and scrcpy:

      Win­dows via Choco­latey(Run as Ad­min­is­tra­tor)

      choco install adb scrcpy -y

      Linux Plat­form (Ubuntu/​De­bian)

      sudo apt install adb scrcpy -y

    Use scrcpy via ADB

    1. Connect Android device to computer via USB.

      • En­sure the de­vice is rec­og­nized by run­ning:

        adb devices
      • If device is listed, you're ready to proceed. If not, check USB connection and drivers.
    2. Run scrcpy:

      • Open a ter­mi­nal or com­mand prompt and sim­ply run:

        scrcpy
      • This will launch the scrcpy window, mirroring Android device's screen.
    3. Wireless Connection (Optional):

      • If you want to use scrcpy wire­lessly, fol­low these steps:

        1. Connect device via USB initially.
        2. Enable wireless debugging:

    2025-02-05_Wireless-Debugging.jpg
    2025-02-05_Wireless-Debugging.jpg

    - Go to **Settings** > **Developer options** > Enable **Wireless debugging**.
    
    3. Pair device with computer:

    2025-02-05_Pair.jpg
    2025-02-05_Pair.jpg

    adb pair <IP>:<PORT>
    (Replace `<IP>` and `<PORT>` with the values shown in the Wireless debugging settings on device.)
    
       ```bash
        adb pair 172.16.8.56:35953
       ```
    
       Enter pairing code: `672265`
    
       > Successfully paired to 172.16.8.56:34121 [guid=adb-DYDMMFWC6XFAX4MN-2bJXjj]
    
    
    
    4. Disconnect the USB cable.
    
    5. Connect wirelessly:

    2025-02-05_connect.jpg
    2025-02-05_connect.jpg

    adb connect <IP>:<PORT>
    adb connect 172.16.8.56:34121
    > connected to 172.16.8.56:34041
    
    6. Run `scrcpy` as usual:

    2025-02-05_154955.jpg
    2025-02-05_154955.jpg

    scrcpy
    7. Run `scrcpy` with TCP/IP:
    
       ```bash
       scrcpy --tcpip=<IP>:<PORT>
       ```
    
       ```bash
       scrcpy --tcpip=172.16.8.56:34121
       ```
    
       > `scrcpy --tcpip=<IP>:<PORT>` allows direct connection to Android device over Wi-Fi.

    Common scrcpy Commands and Options

    scrcpy sup­ports many com­mand-line op­tions for cus­tomiza­tion. Here are some use­ful ones:

    • Reduce resolution:

      scrcpy -m1024

      (Scales the de­vice screen to a max­i­mum width of 1024 pix­els.)

    • Limit frame rate:

      scrcpy --max-fps 30

      (Lim­its the frame rate to 30 FPS.)

    • Record the screen:

      scrcpy --record file.mp4

      (Records the screen to a file named file.mp4.)

    • Disable screen mirroring (only control):

      scrcpy --no-display

      (Use­ful for con­trol­ling the de­vice with­out dis­play­ing its screen.)

    • Turn off the device screen:

      scrcpy --turn-screen-off

      (Mir­rors the de­vice but turns off its screen.)

    • Copy device clipboard to computer:

      scrcpy --forward-all-clipboard

      (Syncs the clip­board be­tween the de­vice and com­puter.)

    • Rotate the device screen:

      scrcpy --rotation 1

      (Ro­tates the de­vice screen. Val­ues: 0 (no ro­ta­tion), 1 (90°), 2 (180°), 3 (270°).)


    Keyboard and Mouse Controls


    Conclusion

    ADB and Scrcpy are pow­er­ful tools for man­ag­ing and con­trol­ling An­droid de­vices.

    With ADB, can push and in­stall APKs, while Scrcpy al­lows to mir­ror and con­trol de­vice’s screen with ease.


    Reference


    Related