7

I am trying my hands on android development using android studio. I have created a project using android studio. Now, I want to track it using git. I have added it into git and everything works fine with my local machine.

But, when I clone it from another machine in different location, opening project in android studio displays very different project structure or prompts some error.

Generally,

Module has been removed from gradle structure. Do you want it to remove from project also?

After digging into bit, I realized that android studio (which is build on intelliJ) stores some hard-coded paths into some project configuration files. (Especially, .iml files). But, changing it to new path is also not working.

Can anybody suggest me proper way to include android studio project into git? Like, what configuration should I do? Which files should I ignore? After cloning it into other machine or path, what changes I should do? etc...

4

1 回答 1

2

您需要检查是否:

  • 您可以将 Android Studio 配置为使用 .iml 中的相对路径(如this old issue、 usingfile://$PROJECT_DIR$/...this issue using 中所示content url="file://$MODULE_DIR$/...

  • 或者您需要注册一个内容过滤器驱动程序(在.gitattributes文件中),能够在结帐时将任何绝对路径替换为$MODULE_DIR$.

弄脏

如果那个 ' smudge' 脚本没有检测到任何东西,你的module.iml将保持不变。
如果它确实检测到绝对路径,则该脚本可以引入适当的修改,您将添加并提交这些修改,以便其他人以更便携的方式重用您的项目。

于 2013-06-20T07:57:45.243 回答