{"record":{"id":"07897fac6e16751a","repo":"dotnet/maui","slug":"adb-keys-were-not-created-successfully","errorCode":null,"errorMessage":"ADB keys were not created successfully.","messagePattern":"ADB keys were not created successfully\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/android.cake","lineNumber":923,"sourceCode":"            keysGenerated = CreateAdbKeysUsingAutomaticGeneration(settings, adbKeyFile, adbKeyPubFile);\n        }\n\t\t\n\t\t// Option 3: Use OpenSSL as fallback (if available)\n        if (!keysGenerated)\n        {\n            Information(\"Option 2 failed. Trying OpenSSL key generation...\");\n            keysGenerated = CreateAdbKeysUsingOpenSSL(adbKeyFile, adbKeyPubFile);\n        }\n        \n        if (!keysGenerated)\n        {\n            throw new Exception(\"All key generation methods failed. Unable to create ADB keys.\");\n        }\n        \n      \t// Verify keys were created\n        if (!System.IO.File.Exists(adbKeyFile) || !System.IO.File.Exists(adbKeyPubFile))\n        {\n            throw new Exception(\"ADB keys were not created successfully.\");\n        }\n\n        Information(\"ADB keys generated successfully!\");\n\n        // Set correct file permissions for ADB keys (Unix systems only)\n        if (IsRunningOnLinux())\n        {\n            Information(\"Setting correct permissions for ADB keys...\");\n            StartProcess(\"chmod\", $\"600 {adbKeyFile}\");\n            StartProcess(\"chmod\", $\"600 {adbKeyPubFile}\");\n        }\n\n        // Set environment variable properly (platform specific)\n        Information(\"Setting ADB_VENDOR_KEYS environment variable...\");\n\n        // This actually sets it for the current process\n        SetEnvironmentVariable(\"ADB_VENDOR_KEYS\", adbKeyPubFile);\n","sourceCodeStart":905,"sourceCodeEnd":941,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/android.cake#L905-L941","documentation":"Thrown when a key-generation method reported success (keysGenerated=true) but the subsequent existence check finds that either adbKeyFile or adbKeyPubFile does not exist on disk. This catches the inconsistent case where the generator returned true without actually writing both files.","triggerScenarios":"keysGenerated is true (so the previous 'all methods failed' check passed) but System.IO.File.Exists(adbKeyFile) || System.IO.File.Exists(adbKeyPubFile) is false — one or both key files are missing despite the success flag.","commonSituations":"A generator wrote only the private key, wrote to a different path than expected, was interrupted, or the file was deleted between generation and verification; a bug in a generator returning true prematurely.","solutions":["Inspect the actual adbKeyFile/adbKeyPubFile paths logged by the script and check what (if anything) was written.","Ensure the target directory exists and is writable before key generation runs.","Review the specific generator method that returned true to see why it didn't write both files.","As a workaround, manually generate the pair with `openssl` and place both files at the expected paths."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (keysGenerated && (!System.IO.File.Exists(adbKeyFile) || !System.IO.File.Exists(adbKeyPubFile))) {\n    throw new Exception($\"Generator reported success but files missing: {adbKeyFile}, {adbKeyPubFile}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Have each generator verify both files exist before returning true.","Log the exact paths written so mismatches are obvious.","Check write permissions/space proactively in minimal containers."],"tags":["android","adb","adb-keys","filesystem","verification"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}