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
Related
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 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 try to import my Android Studio project on different machines and wondering which project files are realy needed. For example the .idea or .gradle directories. I won't to much trash in my svn repo. Can someone tell my more about required files for Android Studio projects?
You need to keep these files in your root project
app folder (tough ignore the build folder inside it recursively, it's a big waste of space)
gradle
.gitignore if you are using GIT
build.gradle
gradle.properties if you want to have the same configuration on all of your pc's. You need to cinfugure it first tough.
gradlew
gradlew.bat
settings.gradle
Anything else that is not on the list and was not created by you, can be ignored
Make sure you ignore these by file name wildcard. This is the garbage created by macs and windows machines.
.DS_Store
desktop.ini
Thumbs.db
*.iml (garbage created by Android studio)
I truely recomend you to use git in Android Studio, the integration is awesome and it`s so easy to use. It select the files u need for you and have really good tools for merge files.
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.
I am using IntelliJ Idea for Android development and IntelliJ uses a folder named out for putting APK file.
I am also using Mercurial as VCS and when I clone the project the out folder is left out from the cloned directory.
Also folder out is also not shown in the project structure and when I go to Open Module Settings -> Modules the folder is excluded as shown in the image below
Why out folder is excluded and how to include it in VCS (Mercurial)?
Why out folder is excluded
Because this folder doesn't contain sources and (I suppose) IntelliJ mirror own settings into .hgignore file of related repository
how to include it in VCS (Mercurial)?
Just
Never do it
because versioning of build artifacts is bad idea, useless, wasted time and space - save only sources, not repeatable results
but, if you want to try all racks on the way - remove the related string from .hgignore.