Android Studio中CreateProcess error=2报错求助:已配git.exe路径仍失败
Let’s work through this frustrating error step by step—you’ve already tried setting the Git path, so let’s dig into the less obvious culprits:
1. Double-Check Your Git Executable Path
First, verify the path you entered actually points to a valid git.exe file:
- Open File Explorer and navigate directly to
C:\Users\Riyaz\Desktop\PortableGit\cmd\ - Confirm
git.exeexists here. Some portable Git versions store the executable in thebinfolder instead ofcmd—if that’s the case, update your path toC:\Users\Riyaz\Desktop\PortableGit\bin\git.exe - In Android Studio, go to
File > Settings > Version Control > Git, paste the corrected path, and click Test to confirm the IDE can reach Git. If the test fails, the path is still wrong or there’s a permission issue.
2. Add Git to Your System PATH
Gradle might be relying on the system’s PATH variable instead of the IDE’s configured path:
- Open Windows System Properties > Advanced > Environment Variables
- Under System Variables, find the
Pathvariable, click Edit - Add
C:\Users\Riyaz\Desktop\PortableGit\cmd(orbin, depending on where yourgit.exeis) to the list - Restart Android Studio completely, then try syncing Gradle again.
3. Check for Permission Restrictions
Desktop folders sometimes have UAC (User Account Control) restrictions that block Android Studio from accessing files:
- Close Android Studio, then right-click its shortcut and select Run as administrator
- Try syncing Gradle again. If this works, you can adjust the folder permissions for your PortableGit directory to avoid running as admin every time.
4. Inspect the IDE Logs for Clues
The error message mentions checking IDE logs—here’s how to get actionable details:
- Go to
Help > Show Log in Explorer(orShow Logdepending on your Android Studio version) - Open the latest log file (look for
idea.log) and search for keywords likeCreateProcess,git, orGradle - Look for lines that specify exactly which path the IDE is trying to access—sometimes it might be using an old cached path instead of your new configuration.
5. Reset Git Configuration in Android Studio
Occasionally, the IDE caches old path settings:
- In
File > Settings > Version Control > Git, delete the path inPath to Git executable - Click Apply, then re-enter the correct path and click Test again
- Sync Gradle once more to see if the error clears.
6. Verify Portable Git is Working Correctly
If none of the above works, check if Git itself is functional:
- Open the Git Bash terminal included with your PortableGit installation
- Run the command
git --version—if this throws an error, your portable Git installation might be corrupted. Try re-downloading and extracting the portable Git archive to a new location.
Let me know if any of these steps resolve your issue, or if you find specific details in the logs that we can troubleshoot further!
内容的提问来源于stack exchange,提问作者xinaxek

