MuntashirAkon/AppManager · error · java.io.IOException

ADB daemon not running.

Error message

ADB daemon not running.

What it means

When switching to ADB mode on Android 11+, findAdbPort tries to auto-discover the local adbd TCP port, but only after confirming the ADB daemon (adbd) is running via AdbUtils.isAdbdRunning(). If adbd is not running, an IOException 'ADB daemon not running.' is thrown and the caller falls back to the default port.

Solutions

  1. Enable Developer Options and turn on USB (or Wireless) debugging on the device
  2. Retry Ops.init after enabling debugging so isAdbdRunning() finds adbd
  3. Provide/confirm the ADB port manually with Ops.setAdbPort if auto-discovery is unavailable
  4. Catch this IOException and fall back to the default port rather than aborting the flow

Example fix

// before
int port = findAdbPort(context, timeout, DEFAULT_ADB_PORT);
// after
int port;
try {
    port = findAdbPort(context, timeout, DEFAULT_ADB_PORT);
} catch (IOException e) {
    Log.w(TAG, "ADB port discovery failed, using default", e);
    port = DEFAULT_ADB_PORT;
}
Defensive patterns

Strategy: fallback

Validate before calling

if (!AdbUtils.isAdbdRunning()) {
    // adbd not started; skip port discovery and use default or prompt user
}

Try / catch

try {
    port = findAdbPort(context, timeout, DEFAULT_ADB_PORT);
} catch (IOException e) {
    port = DEFAULT_ADB_PORT; // adbd not running or discovery failed
} catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    port = DEFAULT_ADB_PORT;
}

Prevention

When it happens

Trigger: Calling Ops.init in ADB-related modes on a device where adbd is not started, e.g. 'Wireless debugging' disabled or USB debugging disabled so no adbd process exists.

Common situations: User enables ADB mode in the app but never enabled Developer Options/USB debugging, adbd stopped after reboot, or a custom ROM without adbd support.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/721a4f292e0a66b2. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/settings/Ops.java:1064

        } finally {
            sTransitionLock.unlock();
        }
    }

    @WorkerThread
    @RequiresApi(Build.VERSION_CODES.R)
    @NoOps
    private static int findAdbPort(@NonNull Context context, long timeoutInSeconds)
            throws IOException, InterruptedException {
        return AdbUtils.getLatestAdbDaemon(context, timeoutInSeconds, TimeUnit.SECONDS).second;
    }

    @WorkerThread
    @NoOps
    private static int findAdbPort(@NonNull Context context, long timeoutInSeconds, int defaultPort)
            throws IOException {
        if (!AdbUtils.isAdbdRunning()) {
            throw new IOException("ADB daemon not running.");
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            // Find ADB port only in Android 11 (R) or later
            try {
                return findAdbPort(context, timeoutInSeconds);
            } catch (IOException | InterruptedException e) {
                Log.w(TAG, "Could not find ADB port", e);
            }
        }
        return defaultPort;
    }

    @AnyThread
    public interface AdbConnectionInterface {
        // TODO: 8/4/24 Remove the first two methods since the third method can be used instead of them
        void connectAdb(int port);

        @RequiresApi(Build.VERSION_CODES.R)

View on GitHub (pinned to 0152f468fc)