{"record":{"id":"73d1e7ec73bf9471","repo":"apache/cordova-android","slug":"android-home-environment-variable-is-set-to-non","errorCode":null,"errorMessage":"'ANDROID_HOME' environment variable is set to non-existent path: ${process.env.ANDROID_HOME}\nTry update it manually to point to valid SDK directory.","messagePattern":"'ANDROID_HOME' environment variable is set to non-existent path: (.+?)\nTry update it manually to point to valid SDK directory\\.","errorType":"validation","errorClass":"CordovaError","httpStatus":null,"severity":"error","filePath":"lib/check_reqs.js","lineNumber":236,"sourceCode":"            }\n            if (avdmanagerInPath) {\n                let sdkPath = null;\n                if (/cmdline-tools/.test(avdmanagerInPath)) {\n                    sdkPath = path.resolve(avdmanagerInPath, '../../../..');\n                    maybeSetAndroidHome(sdkPath);\n                } else {\n                    throw new CordovaError('Failed to find \\'ANDROID_HOME\\' environment variable. Try setting it manually.\\n' +\n                        'Detected \\'avdmanager\\' command at ' + parentDir + ' but does not appear to be within an Android SDK installation.\\n' +\n                        'Try reinstall Android SDK or update your PATH to include valid path to SDK');\n                }\n            }\n        }\n        if (!process.env.ANDROID_HOME) {\n            throw new CordovaError('Failed to find \\'ANDROID_HOME\\' environment variable. Try setting it manually.\\n' +\n                'Failed to find \\'android\\' command in your \\'PATH\\'. Try update your \\'PATH\\' to include path to valid SDK directory.');\n        }\n        if (!fs.existsSync(process.env.ANDROID_HOME)) {\n            throw new CordovaError('\\'ANDROID_HOME\\' environment variable is set to non-existent path: ' + process.env.ANDROID_HOME +\n                '\\nTry update it manually to point to valid SDK directory.');\n        }\n        // Next let's make sure relevant parts of the SDK tooling is in our PATH\n        if (hasAndroidHome && !adbInPath) {\n            process.env.PATH += path.delimiter + path.join(process.env.ANDROID_HOME, 'platform-tools');\n        }\n        if (hasAndroidHome && !avdmanagerInPath) {\n            const cmdLineToolsBin = AndroidCommandLineTools.getBinPath();\n            if (cmdLineToolsBin) {\n                process.env.PATH += path.delimiter + cmdLineToolsBin;\n            }\n        }\n        return hasAndroidHome;\n    });\n};\n\nmodule.exports.check_android_target = function (projectRoot) {\n    // valid_target can look like:","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/lib/check_reqs.js#L218-L254","documentation":"check_android accepts a set or inferred ANDROID_HOME, then verifies the directory actually exists with fs.existsSync. Thrown when the variable points nowhere - the value survives env expansion but the directory itself is missing.","triggerScenarios":"`cordova requirements android` / build with ANDROID_HOME containing a typo, a stale path (SDK moved or uninstalled), an unexpanded '~' inside quotes, or a wrong CI secret value.","commonSituations":"SDK directory renamed after a major version change; macOS/Linux '~' not expanded because the assignment used quotes; CI secret defined once and never updated after the SDK image changed.","solutions":["Find the real SDK path (Android Studio > Settings > Languages & Frameworks > Android SDK, or the parent of your working adb's directory).","Export the corrected ANDROID_HOME, making sure to use $HOME instead of a quoted ~.","If the SDK really is gone, reinstall it (Android Studio or cmdline-tools + sdkmanager)."],"exampleFix":"# before\nexport ANDROID_HOME=\"~/Android/Sdk\"   # '~' is literal inside double quotes\n\n# after\nexport ANDROID_HOME=\"$HOME/Android/Sdk\"","handlingStrategy":"validation","validationCode":"const home = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;\nif (home && !fs.existsSync(home)) {\n  throw new Error(`ANDROID_HOME=${home} does not exist - fix the path (use $HOME, not a quoted ~)`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await check_reqs.check_android();\n} catch (e) {\n  if (/set to non-existent path/.test(e.message)) {\n    // print the offending value and the detected SDK location from Android Studio/adb\n  }\n  throw e;\n}","preventionTips":["Use $HOME (expanded) instead of '~' inside quoted shell assignments.","Update CI secrets/variables whenever the SDK image path changes.","After moving an SDK, grep your profiles for the old path."],"tags":["android-sdk","android-home","path","environment-variable"],"backgroundTag":"env-var-points-to-missing-path","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}