Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collaborating on Android Studio Project using git

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...

like image 463
Rumit Parakhiya Avatar asked Jun 20 '13 07:06

Rumit Parakhiya


People also ask

How do I collaborate a project in Android Studio?

Collaboration Features Provided by Android Studio Extensions Access the extensions marketplace in Android Studio (Android Studio >> Preferences >> Plug-ins) and quickly run a search for "collaboration." A list of extensions with different collaboration features will return.

Can you collaborate on git?

Collaboration is the way different people can work on the same project together. It is like creating a group in GitHub just like Groups in other social media. The people added to the collaborator's list can be able to push, merge, and do other kinds of similar things on the project. Step 2: Add files to your project.

Does Android Studio work with git?

In Android Studio, go to VCS > Enable Version Control Integration. This option won't be visible if it's integrated with any version control before. Then choose Git as the version control system.


1 Answers

You would need to check if:

  • you can configure Android Studio to use relative paths in the .iml (as shown in this old issue, using file://$PROJECT_DIR$/..., or this issue using content url="file://$MODULE_DIR$/...)

  • or you would need to register a content filter driver (in a .gitattributes file) able to replace, on checkout, any absolute path by $MODULE_DIR$.

smudge

If that 'smudge' script doesn't detect any, your module.iml will be unchanged.
If it does detect absolute path, that script can introduce the proper modifications, and you will add and commit those, for others to reuse your project in a more portable way.

like image 73
VonC Avatar answered Nov 08 '22 21:11

VonC