Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Android Studio Project from Git

I have and android studio project that I have checked into git. My git ignore file looks like:

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iws
.idea/workspace.xml
.idea/tasks.xml

/gradle

When I go to my laptop to pull the project down I am not sure whether I should do open or import inside android studio to correctly being in the project. When I do open I get the following error:

Cannot load module file 'D:\dev\android\projects\projectname\ProjectName.iml':
File D:\dev\android\projects\projectname\ProjectName.iml does not exist

Even though that file does exist.

When I do import instead of open android studio asks for the path to gradle home and I am not sure what to put in. I am using android studio 0.4.3.

Any help would be really appreciated.

Answer:

I was able to get the project to build by doing open instead of import. However in the process intellij created an additional iml file at the root of my project which doesn't exist on my desktop. Not sure why it was created and if I need it. Can't for the life of me figure out the proper way to push my project into git and then restore it on another machine without causing lots of new files to be generated and break things.

like image 925
Nath5 Avatar asked Feb 04 '14 01:02

Nath5


People also ask

How do I download an Android project from GitHub?

You can directly import GitHub projects into Android Studio. File -> New -> Project from Version Control -> GitHub. Then enter your GitHub username and password. Select the repository and hit clone.

Can I Import an Android Studio project?

Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.

How do I copy a project from GitHub to Android Studio in Terminal?

On github web, go to the repo you want yo clone and click on the download button (code) then copy the url where it says clone with https. In Android Studio 4.0, go to VCS (if you've added a github plugin) then click on Get From Version Control, it will load a window where you'll paste in the url you got from github.


1 Answers

Use import and delete "/gradle" out of your .gitignore Its ok to ignore .gradle, but /gradle should be included in the git.

At least this is the way i got it working for me.

like image 55
danijoo Avatar answered Oct 16 '22 19:10

danijoo