{"record":{"id":"2c43852ad8a63a3f","repo":"skylot/jadx","slug":"attach-failed","errorCode":null,"errorMessage":"Attach failed","messagePattern":"Attach failed","errorType":"exception","errorClass":"SmaliDebuggerException","httpStatus":null,"severity":"error","filePath":"jadx-gui/src/main/java/jadx/gui/device/debugger/SmaliDebugger.java","lineNumber":158,"sourceCode":"\t\t\tbyte[] bytes = JDWP.IDSizes.encode().getBytes();\n\t\t\tJDWP.setPacketID(bytes, 1);\n\t\t\tLOG.debug(\"Connecting to ADB {}:{}\", host, port);\n\t\t\tSocket socket = new Socket(host, port);\n\t\t\tInputStream inputStream = socket.getInputStream();\n\t\t\tOutputStream outputStream = socket.getOutputStream();\n\n\t\t\tsocket.setSoTimeout(5000);\n\t\t\tJDWP jdwp = initJDWP(outputStream, inputStream);\n\t\t\tsocket.setSoTimeout(0); // set back to 0 so the decodingLoop won't break for timeout.\n\n\t\t\tSmaliDebugger debugger = new SmaliDebugger(suspendListener, port, jdwp, inputStream, outputStream);\n\n\t\t\tdebugger.decodingLoop();\n\t\t\tdebugger.listenClassUnloadEvent();\n\t\t\tdebugger.initPools();\n\t\t\treturn debugger;\n\t\t} catch (IOException e) {\n\t\t\tthrow new SmaliDebuggerException(\"Attach failed\", e);\n\t\t}\n\t}\n\n\tprivate void onSuspended(long thread, long clazz, long mth, long offset) {\n\t\tsuspendInfo.update()\n\t\t\t\t.updateThread(thread)\n\t\t\t\t.updateClass(clazz)\n\t\t\t\t.updateMethod(mth)\n\t\t\t\t.updateOffset(offset);\n\t\tif (suspendInfo.isAnythingChanged()) {\n\t\t\tSUSPEND_LISTENER_QUEUE.execute(() -> suspendListener.onSuspendEvent(suspendInfo));\n\t\t}\n\t}\n\n\tpublic void stepInto() throws SmaliDebuggerException {\n\t\tsendStepRequest(suspendInfo.getThreadID(), JDWP.StepDepth.INTO);\n\t}\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-gui/src/main/java/jadx/gui/device/debugger/SmaliDebugger.java#L140-L176","documentation":"Error \"Attach failed\" thrown in skylot/jadx.","triggerScenarios":"Thrown at jadx-gui/src/main/java/jadx/gui/device/debugger/SmaliDebugger.java:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the target device/emulator is reachable and the debuggable process is running before attaching; surface the underlying IOException cause to the user.","Retry the attach after verifying the ADB forward port is still open, and fail with instructions to restart ADB if the connection was refused."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}