git android studio project,Import Android Studio project from git into Android Studio (Gradle)

问题

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:

da382d19148dae4769c04c4941dabc04.png

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:

116dec92dfcd40ce4247e41b65a4431c.png

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

013c29ce9f92309a423fac02bcc106a4.png

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

3109e8650669564ed330294e92585b99.png

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:

b6cb7adfbdfeb0cd31720574d7dd32fe.png

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

232f319b7d1b1d1fcb6cb0f25a2d5592.png

Create project from existing sources

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

e8b885745f398c76843549c41d4b830c.png

d6a4a9cb115bc2646f43ab4d0e1099ed.png

d05e878a85bcb88b9a5bfceb9d0df94d.png

Results in this, I was expecting app directory:

0c63ecc88bc190ce2383c5348e83653e.png

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):

f6c07e2dfd5968d363ee96ae43d46b4f.png

回答1:

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.

回答2:

Choose Existing Sources instead of Import

回答3:

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.

来源:https://stackoverflow.com/questions/30127943/import-android-studio-project-from-git-into-android-studio-gradle

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值