{"record":{"id":"c286d727e5bb47e1","repo":"apache/cordova-android","slug":"failed-to-find-android-home-environment-variable-c286d7","errorCode":null,"errorMessage":"Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.\nFailed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.","messagePattern":"Failed to find 'ANDROID_HOME' environment variable\\. Try setting it manually\\.\nFailed to find 'android' command in your 'PATH'\\. Try update your 'PATH' to include path to valid SDK directory\\.","errorType":"validation","errorClass":"CordovaError","httpStatus":null,"severity":"error","filePath":"lib/check_reqs.js","lineNumber":232,"sourceCode":"                    throw new CordovaError('Failed to find \\'ANDROID_HOME\\' environment variable. Try setting it manually.\\n' +\n                        'Detected \\'adb\\' command at ' + parentDir + ' but no \\'platform-tools\\' directory found near.\\n' +\n                        'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'platform-tools directory.');\n                }\n            }\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    });","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/lib/check_reqs.js#L214-L250","documentation":"Terminal fallback of check_android: after all inference attempts (adb layout, avdmanager cmdline-tools layout), process.env.ANDROID_HOME is still empty. The message is generic because no tool gave a location to report - the SDK simply was not detectable.","triggerScenarios":"`cordova requirements android` / build / run on a machine where ANDROID_HOME and ANDROID_SDK_ROOT are unset and neither adb nor avdmanager is on PATH (or both inference branches above were skipped).","commonSituations":"Fresh machine or minimal CI container with no Android SDK installed; shell profile not sourcing the env exports; CI job missing the environment block.","solutions":["Install an Android SDK (Android Studio, or download command-line tools and run sdkmanager).","Export ANDROID_HOME (and ANDROID_SDK_ROOT for older tooling) in ~/.profile or the CI environment.","Verify with `cordova requirements android` - all checks should pass."],"exampleFix":"# before: no SDK env anywhere\n$ cordova requirements android\n\n# after (~/.profile or CI env)\nexport ANDROID_HOME=\"$HOME/Android/Sdk\"\nexport ANDROID_SDK_ROOT=\"$ANDROID_HOME\"\nexport PATH=\"$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin:$PATH\"","handlingStrategy":"validation","validationCode":"if (!process.env.ANDROID_HOME && !process.env.ANDROID_SDK_ROOT) {\n  throw new Error('ANDROID_HOME is unset and no SDK tools are on PATH - install the Android SDK and export ANDROID_HOME');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await check_reqs.run();\n} catch (e) {\n  if (/Failed to find 'android' command/.test(e.message)) {\n    // no SDK at all: emit setup instructions and fail the job early\n  }\n  throw e;\n}","preventionTips":["Provision the Android SDK as an explicit CI step (or use a managed image) before any cordova command.","Centralize env exports in one profile/script sourced by shells and CI alike.","Run `cordova requirements android` as a smoke test right after environment setup."],"tags":["android-sdk","android-home","environment-variable","ci-setup"],"backgroundTag":"missing-env-var","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}