0

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.

Ignacio Martin
  • 264
  • 2
  • 11

2 Answers2

0

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.

ahasbini
  • 6,761
  • 2
  • 29
  • 45
  • The thing is that I would like to copy also the settings of the project, running configurations included. I'll edit the question. – Ignacio Martin Jan 26 '18 at 08:34
  • Then I believe the file that needs to be kept is the `.idea/workspace.xml`. To be honest haven't tried it before but I looked into the file and it seems it contains all the run/debug configs in it – ahasbini Jan 26 '18 at 11:03
0

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

Ignacio Martin
  • 264
  • 2
  • 11