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.
Related
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
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.
I have just uploaded my Android Project to my github repo and noticed that the volley folder is greyed out and can't be accessed.
So I took a closer look at my volley folder, inside my MyApplication folder and noticed a .gitignore file in it. Funny thing tho I didn't create the file. Is there a reason for this? Shouldn't I get rid of this file and upload my volley folder?
If someone downloads my Project and tries to run it, Android Studio will probably look for a volley folder that just isn't there?.. Am I missing something or ?
Thank you!
.gitignore is automatically included in volley project when you clone(or download) it from AOSP repository. Here is the content of .gitignore you originally face to:
bin
gen
.gradle
build
.settings
target
*.iml
.idea
local.properties
As you can see in the volley repository, there are no files or folders listed above. Therefore, you have not included none of the items in your project except src folder that you have compiled it in your project. So, don't worry. Nothing wrong would happen with it.
.gitignore is created automatically when you create a repo for a project. You should put inside it the path to files that you don't want to be uploaded to git, basically files that must be ignored like a database file.
My android studio project is ostensibly error-free and (usually) builds just fine. But as seen in the following picture, there is a set of files that shows up twice in the file tree:
...once at the same level as the root project folder, and once within the project folder. NOTE: The actual files on the file system are ONLY located within the project folder.
In Android Studio, when I try to edit the settings.gradle within the project folder, it tells me "This folder does not belong to a Gradle project. Make sure it is registered in settings.gradle.", as shown here:
So, I try to instead edit the settings.gradle outside the project folder. In that case the Non-Project Files Access window comes up: this file is not part of my project. As shown here:
Who knew Android Studio was designed by Franz Kafka! But seriously, has anybody seen this? Or do you have any thoughts? Because of this issue, I can't add any new libs, so it is quite a show-stopper.
You may be interested to know that there in my git repo, there are existing versions of several auto-generated files including app.iml and project.iml and some other files from .idea/. When I git checkout back to the ones in the repo, the duplicate-file-trees briefly disappear. (I am still unable to access/edit settings.gradle, though).
If you want more information let me know. Thanks!
With the change to the Gradle build system, I've noticed a bunch of *.xml files added to the .idea/libraries project directory. I'd assume this is how Android Studio/IntelliJ links libraries to the project.
Is it ok/recommended to add .idea/libraries to .gitignore? Since gradle handles all dependencies, I'd think either way these would be added/overwritten. Hoping for some confirmation.
Yes, why not.
I've been ignoring the whole .idea directory in my .gitignore, to avoid unnecessary changes get into the repo. Those IDE configurations can be regenerated from Gradle files.