Can I delete these build folders when I am not running Android Studio?

29,059

Solution 1

will my project rebuild again on next startup

Yes. For situations where backups are expensive in terms of space, time, or money, follow the rules for what goes into version control (e.g., git), and back up only those things.

Solution 2

If you are using a unix based OS you might be able to run following command using terminal:

 find . -name build -exec rm -rf {} \;

which causes to delete all build folders inside a specific folder.

Solution 3

Removing the build file doesn't mess up application but yes it gets created again and it rebuilds the application. If you read the below link they have clearly mentioned why build file is created and required.

https://developer.android.com/studio/build/index.html

Hope this helps.

Solution 4

You can do one thing as I do. Just keep app folder and delete remaining folders. When you need to use that project again. Create new project and replace that app folder with your and done.

Solution 5

The best practice is to use a version control system like git, it generates a .gitignore file where the unnecessary files are mentioned. (this files are created then by youy IDE) example of gitignore:

.iml

.gradle

/local.properties

/.idea/workspace.xml

 /.idea/libraries

.DS_Store

/ build

/ captures

.externalNativeBuild

*.idea

.idea / modules.xml
Share:
29,059

Related videos on Youtube

Usman
Author by

Usman

Updated on December 26, 2020

Comments

  • Usman
    Usman over 3 years

    I am backing up android studio projects in google drive and I found that the build folders contain thousands of files, so google drive ends up tired.

    My practice is that I run the 'clean project' command in Android Studio before exiting so that the unnecessary files are cleaned and only the important files remain to be backed up. But still sometimes the build folder remains there with many files.

    My question is that if I delete these two build folders manually (see screenshot), will my project rebuild again on next startup, or will it mess up my project?

    Two build folders

    • Kathir
      Kathir over 5 years
      Yes, you can safely delete those. The Android Studio has an Export to zip file option under the File menu that automatically zips the entire project folder excluding build folders and cache (Not sure when this was introduced, I have it in version 3.2)
    • Zoe stands with Ukraine
      Zoe stands with Ukraine about 5 years
      I've rolled back your edit, because answers go in the answer section. If you have an alternative solution, post an answer rather than editing the question.
    • Usman
      Usman about 5 years
      This edit cannot be an answer because the question is entirely different and my edit does not answer the question in any way. I wrote this because this was related and people interested in the question would find it useful.
  • Stanisław Chmiela
    Stanisław Chmiela over 3 years
    This has a potential to delete all build directories, not just the Android-related ones which may be dangerous and unwanted (eg. in mixed TS/Android projects one could be storing JS in build — why clearing Android files should clear JS too). For what it's worth I have been able to delete only android/build directories using: find ./**/android -name 'build' -type d -prune -print -exec rm -rf '{}' \;
  • Rohan Kandwal
    Rohan Kandwal over 2 years
    @StanisławChmiela Used your command to delete about 50 GB of old build folders I had accumulated for past 8 years of development. Great find.