android sdk更新失败Failed to create directory C:\ Program Files\Android\android-sdk\temp

本文解决Windows 7用户在安装SDK平台工具时遇到的Failed to create directory...错误问题。提供了两个解决方案:一是完全禁用用户账户控制设置;二是确保对指定文件夹有写权限,并以管理员身份运行Eclipse或SDK管理器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Fixing “Failed to create directory…” error while installing SDK Platform

解决SDK平台安装失败的问题


This is a common problem faced by Windows 7 users while installing SDK Platform Tools. The error says:
Downloading Android SDK Platform-tools, revision 7
Failed to create directory C:\ Program Files\Android\android-sdk\temp
Downloading SDK Platform Android 2.3.3, API 10, revision 2
Failed to create directory C:\ Program Files\Android\android-sdk\temp
Downloading SDK Platform Android 2.2, API 8, revision 3
Failed to create directory C:\ Program Files\Android\android-sdk\temp
Downloading SDK Platform Android 2.1, API 7, revision 3
Failed to create directory C:\ Program Files\Android\android-sdk\temp

解决方法一:

To fix this issue you need to disable your UAC (User Account Control) setting completely. Go to Control Panel > User Accounts and Family Safety > User Accounts > Change User Accounts Control Settings. Click there and this will open a new Window for UAC permissions or Click on Windows Button > Type UAC > Hit EnterDrag down the slider to Never notify and Click Ok. After that, restart Windows to apply settings.

按上面步骤,更改用户账户控制设置,然后重新启动即可。如下图:



解决方法二:(推荐)

Make sure you have writing permissions for that folder. Try starting Eclipse or the SDK Manager as Administrator.

确保对这个文件夹有写的权限,以管理员方式运行Eclipse。



不要发这种 ”步骤1: 更新脚本文件 替换 Setup-Environment.ps1 中的 Install-DotNetSDK 和 Fix-EnvironmentPath 函数 替换 ProjectEcosystemManager.ps1 中的 Resolve-Executable 函数“我看不懂 也不会改 我只做了解决方案的部分 小蓝窗”PS C:\Users\Administrator> # 更新 Setup-Environment.ps1 中的 Install-DotNetSDK 函数 >> function Install-DotNetSDK { >> Write-Host "Installing .NET SDK..." >> >> # 直接下载安装包(使用可靠链接) >> $dotnetUrl = "https://download.visualstudio.microsoft.com/download/pr/8d5ffbe0-0e5b-4d9e-84aa-7950d7e2c4bd/dotnet-sdk-8.0.300-win-x64.exe" >> $dotnetInstaller = "$tempDir\dotnet-installer.exe" >> >> # 使用重试机制下载 >> $retryCount = 0 >> $maxRetries = 3 >> $downloadSuccess = $false >> >> while ($retryCount -lt $maxRetries -and -not $downloadSuccess) { >> try { >> Write-Host "Attempt $($retryCount+1) to download .NET SDK..." >> Invoke-WebRequest -Uri $dotnetUrl -OutFile $dotnetInstaller -ErrorAction Stop >> $downloadSuccess = $true >> Write-Host "✅ .NET SDK download successful" -ForegroundColor Green >> } >> catch { >> $retryCount++ >> Write-Host "⚠️ Download failed: $_" -ForegroundColor Yellow >> Start-Sleep -Seconds 5 >> } >> } >> >> if (-not $downloadSuccess) { >> Write-Host "❌ Failed to download .NET SDK after $maxRetries attempts" -ForegroundColor Red >> Write-Host "Manual download link: https://dotnet.microsoft.com/en-us/download/dotnet/8.0" >> exit 1 >> } >> >> # 安装.NET SDK >> try { >> Write-Host "Installing .NET SDK..." >> $process = Start-Process $dotnetInstaller -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru >> >> if ($process.ExitCode -eq 0) { >> Write-Host "✅ .NET SDK installed successfully" -ForegroundColor Green >> } >> else { >> Write-Host "⚠️ .NET SDK installation exited with code $($process.ExitCode)" -ForegroundColor Yellow >> } >> } >> catch { >> Write-Host "❌ .NET SDK installation failed: $_" -ForegroundColor Red >> exit 1 >> } >> >> # 验证安装 >> if (-not (Test-Path "C:\Program Files\dotnet\dotnet.exe")) { >> Write-Host "❌ .NET SDK not found after installation" -ForegroundColor Red >> exit 1 >> } >> } >> PS C:\Users\Administrator> # 更新 ProjectEcosystemManager.ps1 中的 Resolve-Executable 函数 >> function Resolve-Executable { >> param([string]$name) >> >> $logMessage = "Resolving $name executable..." >> $logMessage | Out-File $logFile -Append >> >> # 1. 检查已知安装路径 >> $knownPaths = @( >> "C:\Program Files\nodejs\$name.exe", >> "C:\Program Files\dotnet\$name.exe", >> "C:\Program Files (x86)\nodejs\$name.exe", >> "C:\Program Files (x86)\dotnet\$name.exe", >> "$env:ProgramFiles\nodejs\$name.exe", >> "$env:ProgramFiles\dotnet\$name.exe" >> ) >> >> foreach ($path in $knownPaths) { >> $logMessage = "Checking: $path" >> $logMessage | Out-File $logFile -Append >> >> if (Test-Path $path) { >> $logMessage = "✅ Found at: $path" >> $logMessage | Out-File $logFile -Append >> return $path >> } >> } >> >> # 2. 使用系统PATH查找 >> $pathDirs = $env:PATH -split ';' >> foreach ($dir in $pathDirs) { >> if ([string]::IsNullOrWhiteSpace($dir)) { continue } >> >> $exePath = Join-Path $dir "$name.exe" >> $logMessage = "Checking PATH: $exePath" >> $logMessage | Out-File $logFile -Append >> >> if (Test-Path $exePath) { >> $logMessage = "✅ Found in PATH: $exePath" >> $logMessage | Out-File $logFile -Append >> return $exePath >> } >> } >> >> # 3. 终极手段:创建符号链接 >> try { >> $systemDir = "$env:SystemRoot\System32" >> $exePath = Join-Path $systemDir "$name.exe" >> >> if ($name -eq "node") { >> $source = "C:\Program Files\nodejs\node.exe" >> } >> elseif ($name -eq "dotnet") { >> $source = "C:\Program Files\dotnet\dotnet.exe" >> } >> >> if (Test-Path $source) { >> $logMessage = "Creating symlink: $exePath -> $source" >> $logMessage | Out-File $logFile -Append >> >> if (-not (Test-Path $exePath)) { >> cmd /c mklink "$exePath" "$source" 2>$null >> } >> >> if (Test-Path $exePath) { >> $logMessage = "✅ Created symlink: $exePath" >> $logMessage | Out-File $logFile -Append >> return $exePath >> } >> } >> } >> catch { >> $errorMsg = "❌ Failed to create symlink: $_" >> $errorMsg | Out-File $logFile -Append >> } >> >> # 所有方法都失败 >> $errorMsg = "❌ Unable to find $name executable after all attempts" >> $errorMsg | Out-File $logFile -Append >> throw $errorMsg >> } >> PS C:\Users\Administrator> # 更新 Setup-Environment.ps1 中的 Fix-EnvironmentPath 函数 >> function Fix-EnvironmentPath { >> Write-Host "Fixing environment variables..." >> >> # 获取当前PATH >> $currentPath = [Environment]::GetEnvironmentVariable("PATH", "Machine") >> >> # 清理重复路径 >> $pathArray = $currentPath -split ';' | >> Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | >> ForEach-Object { $_.TrimEnd('\') } | >> Select-Object -Unique >> >> # 确保关键路径存在 >> $requiredPaths = @( >> "C:\Program Files\nodejs", >> "C:\Program Files\dotnet", >> "C:\Windows\System32", >> "C:\Windows\System32\WindowsPowerShell\v1.0", >> "C:\Sysinternals" >> ) >> >> # 添加缺失的关键路径 >> foreach ($path in $requiredPaths) { >> if ($pathArray -notcontains $path) { >> $pathArray = @($path) + $pathArray >> } >> } >> >> # 重建PATH字符串 >> $cleanPath = $pathArray -join ';' >> >> # 更新系统环境变量 >> [Environment]::SetEnvironmentVariable("PATH", $cleanPath, "Machine") >> >> # 更新当前会话 >> $env:PATH = $cleanPath >> >> Write-Host "✅ Environment variables fixed" -ForegroundColor Green >> Write-Host "New PATH: $cleanPath" >> } >> PS C:\Users\Administrator> # 正确查看日志的方法 >> function Get-ServiceLogs { >> $logDir = "E:\ProjectEcosystem\ProjectMonitor\Logs" >> $latestLog = Get-ChildItem -Path $logDir -Filter "Service_*.log" | >> Sort-Object LastWriteTime -Descending | >> Select-Object -First 1 -ExpandProperty FullName >> >> if ($latestLog) { >> Get-Content -Path $latestLog -Tail 50 -Wait >> } >> else { >> Write-Host "No log files found in $logDir" -ForegroundColor Yellow >> } >> } >> >> # 使用示例 >> Get-ServiceLogs >> === 生态系统管理服务启动于 08/13/2025 22:42:09 === 当前用户: BF-202503252000\Administrator 工作目录: E:\ PATH环境变量: C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Windows\System32;E:\curl-8.15.0_4-win64-mingw\bin;E:\Python310;E:\Python310\Scripts;C:\Windows;\Wbem;\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;E:\ai_temp;C:\Program Files\NVIDIA Corporation\NVIDIA App\NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Miniconda3\Scripts;C:\ProgramData\Miniconda3\Library\bin;C:\Program Files\Microsoft VS Code\bin;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;C:\Sysinternals ❌ 服务启动失败: ❌ 无法找到 === 生态系统管理服务启动于 08/13/2025 22:42:10 === 当前用户: BF-202503252000\Administrator 工作目录: E:\ PATH环境变量: C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\dotnet;C:\Windows\System32;E:\curl-8.15.0_4-win64-mingw\bin;E:\Python310;E:\Python310\Scripts;C:\Windows;\Wbem;\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;E:\ai_temp;C:\Program Files\NVIDIA Corporation\NVIDIA App\NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Miniconda3\Scripts;C:\ProgramData\Miniconda3\Library\bin;C:\Program Files\Microsoft VS Code\bin;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;E:\Python310;E:\Python310\Scripts;E:\ai_temp;C:\Sysinternals ❌ 服务启动失败: ❌ 无法找到“
最新发布
08-14
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值