Skip to main content

What is ADB?

Android Debug Bridge (ADB) is a command-line tool from Google that enables communication between your computer and Android devices. APK Extractor requires ADB to:
  • Connect to Android devices (USB or WiFi)
  • List installed applications
  • Extract APK files from devices
  • Read device properties and metadata
APK Extractor automatically searches for ADB in multiple locations and provides options to download or configure it manually.

Automatic ADB Detection

When you first launch APK Extractor, it automatically searches for ADB in the following order:
  1. config.txt file - Previously saved ADB path
  2. System PATH - Checks if adb command is available
  3. C:\platform-tools\adb.exe - Common installation location
The search logic from server.js:30:
function getAdbPath() {
  if (_adbPathCache) return _adbPathCache;
  if (fs.existsSync(CONFIG_FILE)) {
    const saved = fs.readFileSync(CONFIG_FILE, 'utf8').trim();
    if (saved && fs.existsSync(saved)) { _adbPathCache = saved; return saved; }
  }
  try {
    const found = execSync('where adb', { encoding: 'utf8' }).trim().split('\n')[0].trim();
    if (found) { saveAdbPath(found); return found; }
  } catch { }
  const def = 'C:\\platform-tools\\adb.exe';
  if (fs.existsSync(def)) { saveAdbPath(def); return def; }
  return null;
}
If ADB is found automatically, the path is saved to config.txt for faster startup next time.

Download ADB Automatically

If ADB is not found, APK Extractor can download and install it for you:

Web Interface

The server provides an automated download endpoint at /api/config/download that:
  1. Downloads Android Platform Tools from Google’s official repository
  2. Extracts it to C:\platform-tools\
  3. Saves the path to config.txt
  4. Returns real-time progress via Server-Sent Events (SSE)
The download process (server.js:140):
app.get('/api/config/download', (req, res) => {
  const zipUrl = 'https://dl.google.com/android/repository/platform-tools-latest-windows.zip';
  const zipPath = path.join(os.tmpdir(), 'platform-tools.zip');
  const destDir = 'C:\\';
  
  // Downloads zip file
  const dlCmd = `powershell -Command "Invoke-WebRequest -Uri '${zipUrl}' -OutFile '${zipPath}' -UseBasicParsing"`;
  
  // Extracts to C:\platform-tools
  const extractCmd = `powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`;
  
  // Saves path
  saveAdbPath('C:\\platform-tools\\adb.exe');
});

CLI Tool

The batch script (apk-downloader.bat:122) offers the same functionality:
echo  Descargando Android Platform Tools desde Google...
echo  URL: https://dl.google.com/android/repository/platform-tools-latest-windows.zip

curl -L -o "%TEMP%\platform-tools.zip" "https://dl.google.com/android/repository/platform-tools-latest-windows.zip"

tar -xf "%TEMP%\platform-tools.zip" -C "C:\"

set "ADB_EXE=C:\platform-tools\adb.exe"
echo %ADB_EXE%>"%CONFIG_FILE%"
The automatic download requires administrator privileges to write to C:\platform-tools\. If extraction fails, you’ll need to manually extract the zip file.

Manual Path Configuration

If you already have ADB installed (e.g., from Android Studio), you can manually configure the path.

Via Web Interface

Use the /api/config/path endpoint:
POST /api/config/path
Content-Type: application/json

{
  "path": "C:\\Users\\YourName\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe"
}
The server validates the path exists before saving (server.js:131):
app.post('/api/config/path', (req, res) => {
  const { path: adbPath } = req.body;
  if (!adbPath || !fs.existsSync(adbPath)) {
    return res.status(400).json({ error: 'Ruta inválida o no existe' });
  }
  saveAdbPath(adbPath);
  res.json({ ok: true, adbPath });
});

Via CLI

The batch script prompts for manual input (apk-downloader.bat:102):
echo  Ingresa la ruta completa a adb.exe
echo  Ejemplo: C:\Users\User\AppData\Local\Android\Sdk\platform-tools\adb.exe
set /p USER_ADB="  Ruta: "

if not exist "%USER_ADB%" (
    echo  [!] El archivo no existe en esa ruta.
    goto MANUAL_PATH
)
set "ADB_EXE=%USER_ADB%"
echo %ADB_EXE%>"%CONFIG_FILE%"

config.txt File Format

The config.txt file is a simple text file containing the absolute path to adb.exe:
C:\platform-tools\adb.exe
File location: Same directory as server.js or apk-downloader.bat Format: Single line with the full path (no quotes, no extra whitespace) Save function (server.js:45):
function saveAdbPath(p) {
  _adbPathCache = p.trim();
  fs.writeFileSync(CONFIG_FILE, _adbPathCache, 'utf8');
}
The path is cached in memory (_adbPathCache) for performance. The file is only read once on startup.

Changing the ADB Path

You can change or reset the ADB configuration at any time.

Reset Configuration

Delete the saved path to trigger automatic detection again:
DELETE /api/config
This removes config.txt and clears the cache (server.js:125):
app.delete('/api/config', (req, res) => {
  try { if (fs.existsSync(CONFIG_FILE)) fs.unlinkSync(CONFIG_FILE); } catch { }
  _adbPathCache = null;
  res.json({ ok: true });
});

Update to New Path

Send a new path via POST request (see Manual Path Configuration).

Via CLI

In the batch script, select option [4] Cambiar ruta de ADB from the main menu:
if "%MAIN_CHOICE%"=="4" (
    del "%CONFIG_FILE%" >nul 2>&1
    goto SETUP_ADB
)

Verification

Check if ADB is configured correctly:
GET /api/status
Response:
{
  "configured": true,
  "adbPath": "C:\\platform-tools\\adb.exe"
}
Implementation (server.js:120):
app.get('/api/status', (req, res) => {
  const adb = getAdbPath();
  res.json({ configured: !!adb, adbPath: adb || null });
});
If configured is false, all device operations will fail with “ADB no configurado” error.

Common Locations

ADB is typically found in these locations:
Installation MethodTypical Path
Platform ToolsC:\platform-tools\adb.exe
Android StudioC:\Users\{Username}\AppData\Local\Android\Sdk\platform-tools\adb.exe
ChocolateyC:\ProgramData\chocolatey\bin\adb.exe
System PATHDetected via where adb command

Troubleshooting

ADB Not Found Error

If you see “ADB no configurado” errors:
  1. Check config.txt exists and contains a valid path
  2. Verify the file at that path exists and is executable
  3. Try deleting config.txt to trigger auto-detection
  4. Use the automatic download feature

Path with Spaces

ADB paths with spaces work correctly - they are properly quoted when executing commands (server.js:99):
function adbCmd(args, serial = null) {
  const adb = getAdbPath();
  if (!adb) throw new Error('ADB no configurado');
  const serialFlag = serial ? `-s "${serial}"` : '';
  return `"${adb}" ${serialFlag} ${args}`;
}

Permission Issues

If ADB fails to run:
  • Ensure the ADB executable has execution permissions
  • On Windows, ADB may be blocked by antivirus software
  • Try running APK Extractor as administrator

Build docs developers (and LLMs) love