I know this is a much-discussed topic on stackoverflow, but I just can't figure out how to make this work. I would like to:
- create an Android Studio project
- check the project in with git
- push the project to bitbucket
- pull the project on a different computer
This is the .gitignore I'm using (basically the Android Studio created one, where I removed the *.iml files - cause that didn't work)
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
But somehow, it just won't work. Android Studio won't recognise the Project, no matter what my gitignore file looks like.
So actual question: how do I push an Android Studio project to git so I can simply pull it into another client to continue working?
EDIT:
So here’s how I do things, step-by-step:
- create project GitTest in Android Studio
- create a git repository on Bitbucket
- in Android Studio: select “enable version control integration” - pick “git”
- browse to the gitignore files and change it to match Mauker’s
under “project on the left” select “Project” then under Git “Add”
commit/push the changes (define the remote repo in the process)
at this point, the project is on bitbucket. Next comes the "import project" part:
- open android studio
- select “Check out project from Version Control”
- Import Project from Gradle (using the default grade wrapper as recommended)
- Unregistered VCS root detected -> add root
The project loads, I get some sort of NullPointerException
On the other computer you could try to import the project, instead of opening it.
Actually, you don't have to commit project specific files to your git repo. Android Studio is smart enough to import a project from many different sources.
Just like this:
And here's a nice and more detailed tutorial on how to import a project on Android Studio from source and other places.
For your
.gitignore
file I strongly recommend you to get one usinggitignore.io
website.Also, if you already commited files that are not supposed to be there, check this question and see how you can remove them.
Here's an example of a
.gitignore
file that I use on one of my projects.I've already found this pretty good article about what you're searching for:
https://www.londonappdeveloper.com/how-to-use-git-hub-with-android-studio/
You can also visit CodePath tutorials to find more like:
https://github.com/codepath/android_guides/wiki/Using-Android-Studio
Hope it help