{"record":{"id":"721a4f292e0a66b2","repo":"MuntashirAkon/AppManager","slug":"adb-daemon-not-running-ops","errorCode":null,"errorMessage":"ADB daemon not running.","messagePattern":"ADB daemon not running\\.","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/settings/Ops.java","lineNumber":1064,"sourceCode":"        } finally {\n            sTransitionLock.unlock();\n        }\n    }\n\n    @WorkerThread\n    @RequiresApi(Build.VERSION_CODES.R)\n    @NoOps\n    private static int findAdbPort(@NonNull Context context, long timeoutInSeconds)\n            throws IOException, InterruptedException {\n        return AdbUtils.getLatestAdbDaemon(context, timeoutInSeconds, TimeUnit.SECONDS).second;\n    }\n\n    @WorkerThread\n    @NoOps\n    private static int findAdbPort(@NonNull Context context, long timeoutInSeconds, int defaultPort)\n            throws IOException {\n        if (!AdbUtils.isAdbdRunning()) {\n            throw new IOException(\"ADB daemon not running.\");\n        }\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {\n            // Find ADB port only in Android 11 (R) or later\n            try {\n                return findAdbPort(context, timeoutInSeconds);\n            } catch (IOException | InterruptedException e) {\n                Log.w(TAG, \"Could not find ADB port\", e);\n            }\n        }\n        return defaultPort;\n    }\n\n    @AnyThread\n    public interface AdbConnectionInterface {\n        // TODO: 8/4/24 Remove the first two methods since the third method can be used instead of them\n        void connectAdb(int port);\n\n        @RequiresApi(Build.VERSION_CODES.R)","sourceCodeStart":1046,"sourceCodeEnd":1082,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/settings/Ops.java#L1046-L1082","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Enable Developer Options and turn on USB (or Wireless) debugging on the device","Retry Ops.init after enabling debugging so isAdbdRunning() finds adbd","Provide/confirm the ADB port manually with Ops.setAdbPort if auto-discovery is unavailable","Catch this IOException and fall back to the default port rather than aborting the flow"],"exampleFix":"// before\nint port = findAdbPort(context, timeout, DEFAULT_ADB_PORT);\n// after\nint port;\ntry {\n    port = findAdbPort(context, timeout, DEFAULT_ADB_PORT);\n} catch (IOException e) {\n    Log.w(TAG, \"ADB port discovery failed, using default\", e);\n    port = DEFAULT_ADB_PORT;\n}","handlingStrategy":"fallback","validationCode":"if (!AdbUtils.isAdbdRunning()) {\n    // adbd not started; skip port discovery and use default or prompt user\n}","typeGuard":null,"tryCatchPattern":"try {\n    port = findAdbPort(context, timeout, DEFAULT_ADB_PORT);\n} catch (IOException e) {\n    port = DEFAULT_ADB_PORT; // adbd not running or discovery failed\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt();\n    port = DEFAULT_ADB_PORT;\n}","preventionTips":["Ask users to enable USB/Wireless debugging before ADB mode","Check isAdbdRunning() before attempting discovery","Persist the last known working ADB port as a fallback","Never let port discovery failure abort the whole init flow"],"tags":["android","adb","network"],"backgroundTag":"connection-refused","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}