I have a folder named ".gradle" which is taking 600MB of space.
Normally, it contains a file named fileSnapshots.bin, which is around 20 MB.
But for one of my apps there are several sub folders in which there are several fileSnapshots.bin files created and these are around 150-200MB each.
Please see the following screenshot and tell me if I can delete this folder after closing my project?
If I delete it will my project rebuild safely next time?
Inside the project you can find the .gradle folder.
Inside you can find all settings and other files used by gradle to build the project. You can delete these files without problems. Gradle will recreate it.
Also these file are not committed and Version Control Systems. It means that when you checkout the project these files are not present on the project.
See
You can safely delete all, but you should keep at least 4.1, assuming that is what gradle.properties is using.
You could also prevent this directory from being created for all projects by installing Gradle yourself externally from Android Studio, and configuring it use that instead of Gradle Wrapper.
Related
I have made an Android Studio project. I want to know what folders can i remove from the project. And i can still import it without problems.
As you can see in the screenshot, the project folder contains all those folders and files.
As example is i can remove the release folder.
Now, i want to know what other folders or files can i remove (.gradle, .idea .....)?
Or i mean what are the files that are not related to the project and just generated by the IDE.
In Android Studio, there are generally no useless files. The files that you delete, will be recreated by Android Studio.
You can delete .gradle folder(which contains settings and other files used by gradle to build the project).
Also, app/build, which will be again recreated by Android Studio. And if you want to know what folders/files are generated by IDE, then anything except
app/src
app/proguard-rules.pro
app/libs
app/build.gradle
Project level build.gradle
Anything except above files is generated by IDE.
In short, everything in app folder except app/build is user generated. I'd give a few simple tricks to import other people's project without getting boat-load of gradle errors, but StackOverflow forbids to make statements based on personal experience.
I was pushing my Android application project to my github repository. I saw two folder .gradle and gradle were not pushed but another folder called gradle/wrapper instead got pushed. I am not sure where this gradle/wrapper folder came from and if this is a normal thing that happens when pushing an Android app.
Edit: I closely inspected a bit more and the gradle folder that I was talking about is the gradle/wrapper folder. It is just that I didn't expand that folder initially. The .gradle folder is still not showing up in my Github repository though.
The .gradle folder should not be committed and should be included as part of the gitignore
https://www.gitignore.io/api/android,androidstudio
This is the directory used by the wrapper on your local machine to store the downloaded Gradle dependencies (as compared to installing Gradle separately yourself and configuring the IDE to use that)
build.gradle and settings.gradle should be the least amount of required files for any Gradle project, the wrapper is optional but recommended to standardize the version of Gradle used to build the project
if you don't see a file that you have pushed via git, please check your .gitignore file.
Gradle/wrapper folder is generated upon building.
I'm trying to move my IntelliJ IDEA (2017.3) Android project to another computer just copying the files and it does not work. I am aware of this and this, but in the case of Android project it does not work. All the xml files inside .idea store paths relative to the home ($USER_HOME$) instead of project home ($PROJECT_DIR$). Oddly, Maven projects seem to generate paths relative to the project home and those ones can be copied. But not with gradle projects.
Anyone knows how to solve this ?
EDIT: Bear in mind that I want to copy ALL project settings included running configurations. I want that someone opens the project and find exactly what I have. I know I can reimport the project, but then I'll loose some configuration.
Here's the files and folders that need to be excluded from the copy (assuming that your project has a module called app), preferably if you copy the entire project folder to some where else on the same computer and then deleting the unneeded one by one:
folders .idea, .gradle or any folder who's name starts with a .. They are usually found within the root folder of the project and within the module root folder.
build folder found in the project root folder and in module root folder.
any file who's extension is .iml, found in the project root folder and in module root folder.
local.properties found in project root folder.
The rest of the files and folders need to be kept. With the above excluded, the project can be re-imported in Android Studio properly with the correct configurations relative to your second PC.
On a side note, these are the typical exclusions added in .gitignore of an Android Project Git Repo.
Ok, I found the problem. It is related to how gradle resolve symlinks. This is the issue. Summarizing, if you open your project with a path that contains a symlink, absolute paths will be created in the configuration files and your project won't be portable.
I have reopened the project again using an absolute path and then all the configuration files use PROJECT_DIR instead of USER_HOME
Every project created in Android Studio 1.0.2 contains several files that reference the project's own absolute path. I can't even move my own project directory if I want to, let alone share the project with other developers.
Excluding files in app/build, these are the files containing absolute paths:
.idea/workspace.xml
.idea/modules.xml
.idea/libraries/support_v4_21_0_3.xml
.idea/libraries/appcompat_v7_21_0_3.xml
.idea/gradle.xml
.gradle/2.2.1/taskArtifacts/taskArtifacts.bin
.gradle/2.2.1/taskArtifacts/fileSnapshots.bin
app/app.iml
How do I force Android Studio to use relative paths for everything?
Edit: By experimenting with vanilla IDEA, I've narrowed down the origin of these absolute paths to a specific type of module, which Android Studio apparently always uses without offering you a choice. But I'm still no closer to understanding how to eradicate them.
In IDEA 14.0.2, if you create an empty project or an Android project with an "Application Module", the project does not contain any absolute paths. If you create a project with a "Gradle: Android Module", then it contains absolute paths in the same files as an Android Studio project.
Edit #2: Created IDEA-134587
In general, don't consider any of the .iml files or the contents of the .idea folder to be part of the project, and don't share any of those files, don't check them into source control, and don't move them with the project. Think of them as cache files.
The Gradle files are the source of truth, so if you're having troubles with absolute paths, close the project, delete the non-shareable files, and re-import it from the Gradle build scripts.
I ran into the exact same problem, but the solution suggested above contradicts JetBrains' advice as well as this answer. Also, my co-worker working from the same source code (with unexpanded paths) and Android Studio version wasn't having the problem, so I kept banging my head against the wall.
We eventually solved the problem when we realized that many of the paths I used included symlinks. In my case, I had a symlink set up for ~/work so that it pointed to /some/drive/with/space. Within Android Studio all of my source was referred to from ~/work/source rather than /some/drive/with/space/source. When I changed everything so that Android Studio referred to things with their actual paths, the $PROJECT_DIR$ and $MODULE_DIR$ variables magically started working and my .iml files were no longer getting corrupted. YMMV.
TL;DR: Don't use symlinks in your project paths!
Also, be sure to not keep the files within .gradle as part of your shared project.
Also, one set of files that you might want to share though are your files under .idea/copyright though as that allows you to have shared copyright settings.
So a possible .gitignore file might be:
.gradle
.idea
!.idea/copyright/[YourCopyrightFile].xml
!.idea/copyright/profile_settings.xml
*.iml
build
local.properties
Hmm. I just don't see the same absolute paths in those files, I only see references to MODULE_DIR and PROJECT_DIR, such as:
./app/app.iml: <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
or:
./.idea/workspace.xml: <entry file="file://$PROJECT_DIR$/.idea/libraries/appcompat_v7_21_0_2.xml">
I wonder if this is Linux issue only, or something in your settings?
After switching to my release branch the project had a missing gen file so I added the gen file from java build path.
Now the assets and the res folders are show like gray packages and not folders and I get the errors like res/values/ is missing.
How to return to the standard android project structure in eclipse?
Is there a standard way of returning to the standard Android project. I have become tired to fix project properties and I have tried to clean and restart eclipse It seams that some project metadata is saved the wrong way.
Thanks .
/gen/ folder is automatically generated during compilation. You should include that and /bin/ and also /.properties/ to .gitignore to avoid having to fix properties all the time and also minimise the amount of unnecessary data stored in your repo.