Clean project error with databinding: Unable to delete file androidx.databinding.library.baseAdapters--setter_store.json

10,666

Solution 1

So, the problem is still here but all answers don't solve it. Project doesn't compile for a reason, usually it's some kind of mistake, and if you just delete build folder (which contains file Android Studio is unable to delete) it will not solve problem.

When you are trying to compile project you may get a dozens of errors in generated files (databinding, room, etc). Unfortunatelly, errors are not displaying in the usual window, but if you expand this generated files with errors, you probably will see the real problem, your mistakes you didn't fix when was changing your classes related to generated files. Just fix these mistakes and compile project again. Note: you probably should to look at warnings too.

But if you already got error Unable to delete file you won't see errors in generated files. You need to restart Android studio (if it won't help, you need to delete app\build) and try to compile your project. After that you will find generated files with errors in build tab.

Hope it helps!

Solution 2

I close Android Studio, delete the app\build folder then reopen Android Studio. Note that all instances of AS must be closed for Windows to let you delete the build folder.

Solution 3

Put Below command in Android Studio terminal.

gradlew --stop

Solution 4

I have the same problem, and tried the method mentioned above. I could not find the related class in the error message when I searched in the project directory.

In the end, I suspected that it maybe ~/.gradle problem, and then recompile after deleting, and finally solved.

mv ~/.gradle ~/.gradle_bak

Solution 5

First follow this 4 steps

  • Remove your file generated (build folder)
  • Clean your project ( simply run cmd command - > gradlew clean)
  • Invalidate cache and restart Android Studio
  • Restart computer

If not helpful please try following steps

  • Gradle sync;
  • Reinstall Java JRE & Java SDK;
  • Reinstall the latest version of Android Studio
  • Rolling back to the previous AS version
  • Invalidate cache and restart Android Studio
  • Delete the gradle and .gradle directories in the project directory;
  • Delete the .gradle directory in your directory;
  • Run gradlew clean ( simply run cmd command - > gradlew clean)
Share:
10,666

Related videos on Youtube

LIFED
Author by

LIFED

Updated on July 10, 2022

Comments

  • LIFED
    LIFED almost 2 years

    I use Databinding. Sometimes while I make changes project may be broken. Then I go to Build -> Clean project & Re-Build project. And I get some strange error:

    Unable to delete file: {path_to_project}\app\build\intermediates\data_binding_dependency_artifacts\debug\dataBindingMergeDependencyArtifactsDebug\out\androidx.databinding.library.baseAdapters--setter_store.json
    

    Every time I don't know how to fix it, because I get this error on clean or rebuild. Even if I make Invalidate caches / Restart the problem isn't gone.

    If I try to delete this file manually I get error that file is using by another process. Then I close project and successfully delete this file. But when I open the project and build it I get the same error described above.

    As I can see the problem is about databinding, but I'm not sure because I saw the same problem with other files from other users on StackOverflow. Sometimes problem is gone by itself, but usually it isn't. Maybe the problem occurs because of errors in layout files, but how to find it out if there is no errors in build log.

    Has anyone meet that error? Any ideas how to fix that situation without crush whole the project in undefined time range?

    • Rakesh
      Rakesh about 5 years
      gradlew --stop followed by gradlew clean Command solved my problem
  • Ariel Kruger
    Ariel Kruger about 5 years
    Definitely this was the case for me, some mistake on the code that ends up showing this message, unfortunately Android Studio doesn't display all correct messages yet to guide us to a solution. Thanks for sharing this with us.