12

I've been reading this for hours now and everyone seems to have a different approach or that the tutorials are out of date.

Android Studio .gitignore only includes the app directory, this is on purpose. For what reason I do not know. When trying to clone the git repo Android Studio does not know how to handle it. A very annoying flaw in Android Studio.

What should be in my .gitignore for an Android Studio project?

I have a remote git repo containing the project in the form:

enter image description here

as you can see the git repo contains the /app directory.

I then try to import it via Check out project from Version Control and select git:

enter image description here

Everything works, the Test is successful and then I click on Clone:

enter image description here

The next part I press Yes as git did not clone the entire project but just the essential source files:

enter image description here

This is the part where I am lost, I am guessing I am to create the project via Gradle, so I select Gradle and press Next:

enter image description here

What am I supposed to do here, there are apparently gradle files on the net but which one am I supposed to use:

enter image description here

Create project from existing sources

If I choose Create project from existing sources I get the following problem:

enter image description here

enter image description here

enter image description here

Results in this, I was expecting app directory:

enter image description here

File structure (as you can see fela is missing a lot of files, this is when I chose create project from existing sources, MyApplication is an example of an app which was created in Android Studio):

enter image description here

Community
  • 1
  • 1
basickarl
  • 37,187
  • 64
  • 214
  • 335

3 Answers3

3

The answer is obvious when looking at the .gitignore file of a newly created project. The build.gradle file is and should be included in the push to the remote repo.

So the person who made the repo in my question is doing it wrong. The .gitignore file includes:

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

As seen, more files should of been uploaded to the remote repo.

Nah
  • 1,690
  • 2
  • 26
  • 46
basickarl
  • 37,187
  • 64
  • 214
  • 335
  • Where is the gitignore file? I am having same issue :( http://stackoverflow.com/questions/31188849/git-clone-not-working-on-android-studio/31188913?noredirect=1#comment50383322_31188913 – Fearghal Jul 02 '15 at 15:59
  • @Fearghal The .gitignore file is a *hidden* file, so it might not be visible. It is however visible in Android Studio. The .gitignore file is located in the root directory of your project, for example: .../AndroidStudioProjects/myProject/.gitignore – basickarl Jul 02 '15 at 16:34
  • 1
    thx Karl. I am not sure what you did with the git ignore. I am having same issue with getting a project to compile and run. I have o Gradle file (that i can see) and when i open a specific folder with code it asks me to define the Gradle file. Can you out line what you did with the gitignore file? – Fearghal Jul 02 '15 at 16:57
  • You have not included the correct `.gitignore` file recommendations. Please include it. As this answer says that `.gradle` should be included in `.gitignore` file. However question in this page shows a problem when `.gradle` is included in `.gitignore`. Please clarify this. I am also having similar issue. – Nah Sep 26 '18 at 09:03
0

Choose Existing Sources instead of Import

Danny Buonocore
  • 3,731
  • 3
  • 24
  • 46
0

IF your project is showing error like The project 'xxxxxxx-xx' is not a Gradle-based project then check this link. I hope it helps. This link might cover your possible problem. Let me know the progress.

Roon13
  • 387
  • 2
  • 23
  • Updated question. The link didn't really help as the git project was originally made in Android Studio. So it should work. – basickarl May 08 '15 at 20:41