Skip to main content

Android

1. Introduction to ADB

ADB (Android Debug Bridge) is a command-line tool that allows users to interact with Android devices or emulators. It serves as a crucial debugging tool in Android development, enabling developers to perform operations such as device management, app installation, log viewing, and file transfer. ADB operates on a client-server architecture for communication between a development machine and an Android device.

2. Hardware Connection

Connect the development board to the computer using a Type-C data cable (Note: This USB port is not a power port).

3. ADB Installation (Windows)

  1. Download the ADB package and extract it for use (Click here to download).
  2. Right-click This PC → Select Properties → Go to Advanced system settings → Open Environment Variables.
  3. In System Variables, edit the Path variable and add the extracted ADB directory.
  4. Click OK to save the environment variables.

4. ADB Installation (Ubuntu)

  1. Install ADB using the apt command:

    sudo apt update
    sudo apt install android-tools-adb
  2. ADB login failure.

    # Create or edit the udev rules file:  
    sudo vim /etc/udev/rules.d/51-android.rules

    # Add the following line (grants read/write permissions to plugdev group for device ID 2207:0019):
    SUBSYSTEM=="usb", ATTR{idVendor}=="2207", ATTR{idProduct}=="0019", MODE="0666", GROUP="plugdev"

    # Change file permissions:
    sudo chmod 644 /etc/udev/rules.d/51-android.rules

    # Reload udev rules:
    sudo udevadm control --reload-rules
    sudo service udev restart

    # Reconnect the device to apply changes.

5. ADB Debugging

  1. Press Win + R, type CMD, and open the Windows terminal. Run ADB commands to view related information.

  2. Single device:

    C:\Users\cjw>adb shell
    omni3576:/ $
  3. Multiple devices: List attached devices and reconnect to confirm the target (replace the Type-C cable if unrecognized):

    C:\Users\cjw>adb devices
    List of devices attached
    103ea97dececc831 device
    d48936ed7d1551fc device

    Connect to the development board:

    C:\Users\cjw>adb -s d48936ed7d1551fc shell
    omni3576:/ $

6. ADB App Installation and Uninstallation

6.1 Installation

  1. Basic syntax:

    adb install [options] <apk_file_path>  
    • adb: ADB command prefix.
    • install: Install an APK file.
    • <apk_file_path>: Path to the APK file (use full path or filename if in the current directory).
  2. Common options:

    • -r: Reinstall an existing app while preserving user data.
    • -d: Allow downgrading to an older app version.
    • -s: Install the app to the SD card instead of internal storage.
    • -g: Grant all runtime permissions during installation.
    • -t: Allow installation of test-signed apps.
  3. Example:

    PS D:\Download\NFCTag_CN> adb install test.apk
    3200 KB/s (17677887 bytes in 5.393s)
    Success

6.2 Uninstallation

  1. Basic syntax:

    adb uninstall <package_name>  
    • adb: ADB command tool.
    • uninstall: Remove an app.
    • <package_name>: App package name (e.g., luckfox).
  2. Example:

    adb uninstall luckfox
    • Failure [DELETE_FAILED_INTERNAL_ERROR]: Verify the package name using adb shell pm list packages.
    • Failure [DELETE_FAILED_DEVICE_POLICY_MANAGER]: Disable device admin privileges in SettingsSecurityDevice administrators before uninstalling.