ADB
- ADB Server Configuration
This article details the configuration of the ADB (Android Debug Bridge) server for use with our MediaWiki environment, specifically for testing and debugging mobile applications that interact with the wiki. While seemingly unrelated to the wiki itself, a stable and properly configured ADB server is crucial for developers creating and maintaining our MobileFrontend and related extensions. This guide is intended for newcomers to the server setup process.
What is ADB?
ADB is a versatile command-line tool that lets you communicate with an emulator instance, or a connected Android device. It is part of the Android SDK Platform-Tools package. We use it here primarily for debugging and testing mobile app features, inspecting logs, and installing/uninstalling applications directly onto test devices. A robust ADB server setup is vital for continuous integration and development processes. You can learn more about ADB basics on the official Android Developers documentation.
Server Requirements
Before configuring the ADB server, ensure the following prerequisites are met:
- A Linux server environment (CentOS 7 is our standard).
- Root or sudo privileges.
- Installed Java Development Kit (JDK) – Version 8 or higher is recommended. Confirm with `java -version`. See Java Configuration for details on installing and configuring Java.
- Sufficient disk space for the Android SDK Platform-Tools.
- Network access to the devices or emulators you intend to connect to.
Installation and Configuration
The ADB server isn’t installed as a traditional service. It’s launched as needed. However, we automate its availability through a systemd service.
Step 1: Download Platform-Tools
Download the latest Android SDK Platform-Tools package from the Android Developers website. Choose the Linux version. Extract the archive to a suitable location, such as `/opt/android-sdk/platform-tools`.
Step 2: Set Environment Variables
Add the `platform-tools` directory to your system's `PATH` environment variable. This allows you to execute `adb` commands from any directory. Edit the `/etc/profile` file (system-wide) or `~/.bashrc` (user-specific) and add the following line:
```bash export PATH=$PATH:/opt/android-sdk/platform-tools ```
Remember to source the file after editing: `source /etc/profile` or `source ~/.bashrc`. See Environment Variables for more information about setting up environment variables.
Step 3: Create a Systemd Service
Create a systemd service file to manage the ADB server. Create a file named `/etc/systemd/system/adb.service` with the following content:
```ini [Unit] Description=Android Debug Bridge Server After=network.target
[Service] Type=simple User=root ExecStart=/opt/android-sdk/platform-tools/adb start-server Restart=on-failure RestartSec=5
[Install] WantedBy=multi-user.target ```
Step 4: Enable and Start the Service
Enable the service to start on boot:
```bash sudo systemctl enable adb.service ```
Start the service immediately:
```bash sudo systemctl start adb.service ```
Verify the service is running:
```bash sudo systemctl status adb.service ```
ADB Server Specifications
The following table details the key specifications of our ADB server configuration:
Parameter | Value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Operating System | CentOS 7 (Standard) | Java Version | OpenJDK 1.8.0_275 (Recommended) | ADB Version | 33.0.2 (Latest as of 2023-10-27) | Installation Directory | /opt/android-sdk/platform-tools | Systemd Service File | /etc/systemd/system/adb.service |
Common ADB CommandsHere's a table of frequently used ADB commands:
|