1

I have tried using git with android studio a few times now and always run to the same problem when another developer starts working on the project. its like Android Studio does not recognize it as a project any more.

enter image description here

this happened today after doing a git pull

i have tried adding the gitignore as is suggested in the first answer on Here

but this did not help. i have a safe backup of this project but i do need to get git working for me properly.

I have followed a few different posts different suggestions on setting up git with android studio but they all have landed me in this situation. Some project file must be getting changed when run on other developers machine.

is there a file(s) that i can copy from my back up to fix this issue or additional files that need to be ignored?

enter image description here

1
  • your 'settings.gradle' is empty i think. try solution in my answer. Commented Mar 18, 2016 at 10:43

2 Answers 2

1

This solved the problem for me- add this line to settings.gradle file

include ':app' 

for accessing settings.gradle use 'project' view instead of 'android'.

Then go to file->close project -> open existing android studio project-> select project. if that does not work try file-> invalidate cache and restart

Comment if you dont understand what i mean

Sign up to request clarification or add additional context in comments.

3 Comments

well im happy to help ! ill sleep tonight knowing someone else didnt have to go though 2 days of torture before figuring it out lol. btw I had to do it everytime i pulled the code, so if you figure out a permanent solution then comment here for another one of our fellow comrades who might come wandering some day, looking for answers to his lifes woes :) Im sure it has something to do with git and gitignore
after this worked android studio did not pick up that the project was under git. Did you have this issue aswell?
well close and reopen again. android studio will prompt to "add root". you can check in the project folder too , there surely will be a .git file(possible 'hidden' so enable 'view hidden files and folders'). as long as that file is present your project will be under git
1

Please try after putting below in .gitignore of both app & project module.

In Project module's .gitignore -

 .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures *.iml 

& in app module's .gitignore -

/build app.iml 

Check Screenshot

Hopefully it will work well for you.

4 Comments

Sorry dont know much about modules which directories are each or these in. Does the first snippet go in .gitignore in root of project and the second in the app dir?
updated comments. hopefully now you will able to know.
I have done this but 1.) wont the ignored files still be in the remote and 2.) how do i get the project to run as the only local files i have changed are the 2 gitignore files
first pull your project again and add these changes in respective files and do same with all of your project's peers. then from next time most probably it will not create any problem while using git on android studio.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.