{"record":{"id":"9b50233f83becef2","repo":"stablyai/orca","slug":"emulator-error-9b5023","errorCode":"emulator_error","errorMessage":"Android SDK not found. Install Android Studio and set ANDROID_HOME.","messagePattern":"Android SDK not found\\. Install Android Studio and set ANDROID_HOME\\.","errorType":"exception","errorClass":"EmulatorError","httpStatus":null,"severity":"critical","filePath":"src/main/emulator/android/android-sdk-state.ts","lineNumber":24,"sourceCode":"\n// Resolves the backend's Android SDK. An injected SDK (tests, or an explicit\n// null) is fixed; for the real host it re-runs discovery on every call so a\n// newly-installed SDK or a changed configured path takes effect without a\n// restart. Host discovery is only a few existsSync probes, so this is cheap.\nexport class AndroidSdkState {\n  constructor(\n    private readonly injected: boolean,\n    private readonly injectedSdk: AndroidSdkPaths | null\n  ) {}\n\n  resolve(): AndroidSdkPaths | null {\n    return this.injected ? this.injectedSdk : discoverAndroidSdkFromHost()\n  }\n\n  require(): AndroidSdkPaths {\n    const sdk = this.resolve()\n    if (!sdk) {\n      throw new EmulatorError('emulator_error', SDK_MISSING)\n    }\n    return sdk\n  }\n}\n","sourceCodeStart":6,"sourceCodeEnd":29,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/emulator/android/android-sdk-state.ts#L6-L29","documentation":"Thrown by AndroidSdkState.require when resolve() returns null — meaning no SDK paths were injected and discoverAndroidSdkFromHost failed to locate one. The constant message directs the developer to install Android Studio and set ANDROID_HOME. This is a hard prerequisite gate: every Android backend method calls requireSdk() which routes here.","triggerScenarios":"AndroidSdkState was constructed with injected=false (or injectedSdk=null) and require() is called. discoverAndroidSdkFromHost checked ANDROID_HOME / ANDROID_SDK_ROOT / common install locations and found nothing usable.","commonSituations":"Fresh CI worker without Android Studio; ANDROID_HOME set to a path that doesn't contain the expected platform-tools/emulator binaries; SDK installed via command-line tools only but PATH/env not configured; a Docker container missing the env var; the SDK directory exists but platform-tools is absent.","solutions":["Install Android Studio or the command-line tools and set ANDROID_HOME to the SDK root (the folder containing platform-tools/).","Verify the path actually contains platform-tools/adb, emulator/emulator, and build-tools — discoverAndroidSdkFromHost validates structure, not just existence.","In CI/containers, export ANDROID_HOME (and ANDROID_SDK_ROOT for older tools) before launching the app.","If you have a non-standard location, inject it via AndroidSdkState(true, paths) at construction instead of relying on discovery."],"exampleFix":"# before: env unset\nexport PATH=...\n# after: point at a real SDK\nexport ANDROID_HOME=$HOME/Android/Sdk\nexport ANDROID_SDK_ROOT=$ANDROID_HOME\n# verify structure\nls $ANDROID_HOME/platform-tools/adb $ANDROID_HOME/emulator/emulator","handlingStrategy":"validation","validationCode":"// Verify the SDK is discoverable before any Android operation.\nfunction sdkResolved(state: AndroidSdkState): boolean {\n  return state.resolve() !== null\n}","typeGuard":"import { existsSync } from 'node:fs'\nfunction sdkLooksComplete(p: { adb: string; emulator: string }): boolean {\n  return existsSync(p.adb) && existsSync(p.emulator)\n}","tryCatchPattern":"try {\n  const sdk = sdkState.require()\n} catch (e) {\n  if (e instanceof EmulatorError && e.code === 'emulator_error' && /Android SDK not found/.test(e.message)) {\n    throw new Error('Set ANDROID_HOME to a directory containing platform-tools/ and emulator/')\n  }\n  throw e\n}","preventionTips":["Set ANDROID_HOME (and ANDROID_SDK_ROOT) in the environment before launch.","Confirm platform-tools/adb and emulator/emulator exist in the SDK root.","Inject a known SDK path via AndroidSdkState(true, paths) when discovery is unreliable."],"tags":["android","sdk","environment","configuration","emulator"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}