I had a similar problem that occured after reinstalling Windows 11 24H2 and upgrading from Android Studio Koala to Meerkat. After restoring my project from my backup to my hard drive, opening the project and run, I would get the same error. I think Android Studio got confuse with the permissions between the old OS and the new OS, the old AS and the new AS. Deleting the entire build directory fixed the issue. And yes I did not have to delete the build directory over and over again. Hope it helps someone!