Android Studio Arctic Fox下Gradle任务:app:dexBuilderDebug执行失败(AccessDeniedException)的自动修复方案咨询
:app:dexBuilderDebug AccessDeniedException in Android Studio Arctic Fox Hey, sorry to hear you're stuck with this annoying permission error stopping your builds—manually deleting directories every time is such a hassle. Let's get this sorted with automatic fixes that work even when running as admin:
1. Add a Custom Gradle Clean Task
You can create a Gradle task that automatically deletes the problematic desugar_graph directory right before the dexBuilderDebug task runs. This ensures the directory is fresh and unlocked each time you build.
For Groovy (build.gradle):
// Task to clean the desugar graph output directory task cleanDesugarCache(type: Delete) { delete fileTree(dir: "${project.buildDir}/intermediates/desugar_graph/debug/out") } // Hook the clean task to run before dexBuilderDebug tasks.named('dexBuilderDebug').configure { dependsOn cleanDesugarCache }
For Kotlin DSL (build.gradle.kts):
val cleanDesugarCache by tasks.registering(Delete::class) { delete(fileTree("${project.buildDir}/intermediates/desugar_graph/debug/out")) } tasks.named("dexBuilderDebug") { dependsOn(cleanDesugarCache) }
Just drop this into your app module's build script, and Gradle will handle the cleanup automatically on every debug build.
2. Disable Incremental Desugaring
This permission issue often ties to incremental desugaring's cached files getting locked. Try disabling incremental desugaring by adding this line to your project's gradle.properties file:
android.enableIncrementalDesugaring=false
This makes Gradle rebuild the desugar output from scratch each time instead of reusing cached files, which avoids the lock conflict. Note: It might add a few seconds to your build time, but it's a reliable fix.
3. Turn Off Gradle's File System Watching
Sometimes Gradle's file system watcher locks files in the build directory. Disable it by adding this to gradle.properties:
org.gradle.vfs.watch=false
This prevents Gradle from holding locks on build artifacts, which can resolve the access denied error.
Bonus Checks
- Antivirus/Security Tools: Make sure your antivirus or Windows Defender isn't scanning your project directory—these tools often lock files temporarily. Add your
AndroidProjectsfolder to the exclusion list. - Directory Permissions: Double-check that your user account has full read/write permissions for the
C:\Users\Roman\AndroidDevelopment\AndroidProjects\Projectdirectory (right-click > Properties > Security > Edit > ensure your user has Full Control).
If you want a quick Android Studio setting tweak, you can also enable automatic build cleanup:
- Go to
File > Settings > Build, Execution, Deployment > Compiler - Check
Clear output directory on build(if available) andBuild project automatically - Hit Apply and OK
内容的提问来源于stack exchange,提问作者Roman Popov

