将Android Studio项目从git导入Android Studio(Gradle) [英] Import Android Studio project from git into Android Studio (Gradle)

查看:919
本文介绍了将Android Studio项目从git导入Android Studio(Gradle)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经阅读了几个小时,每个人似乎都有不同的方法,或者教程已过时。

Android Studio .gitignore只包含应用程序目录,这是故意的。出于什么原因我不知道。当试图克隆git仓库时,Android Studio不知道如何处理它。

我的.gitignore应该在Android Studio项目中?



我有一个远程git包含项目形式的回购:

在这里>



你可以看到git repo包含 / app 目录。



然后,我尝试通过从版本控制中检出项目并选择 git



>

一切正常, Test 成功,然后点击 Clone



>

下一部分我按,因为git并没有克隆整个项目,而只是基本的源文件:


这是我失去的部分,我猜我是通过创建项目 Gradle ,所以我选择 Gradle 并按 Next





我应该在这里做什么,网上有明显的gradle文件,但我应该使用哪一个:

< img src =https://i.stack.imgur.com/IygZf.pngalt =在这里输入图片描述>



从现有来源创建项目



如果我选择从现有来源创建项目,则会出现以下问题:





app >目录:



p>

文件结构(您可以看到fela缺少大量文件,这是在我从现有源选择创建项目时,MyApplication是创建的应用程序示例Android Studio):



解决方案

当查看新创建的项目的.gitignore文件时,答案显而易见。 build.gradle文件IS和SHOULD应包含在推送到远程仓库中。



因此,在我的问题中制作仓库的人是做错了。 .gitignore文件包括:

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

如上所示,应该有更多的文件上传到远程仓库。


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:

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:

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

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

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:

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

Create project from existing sources

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

Results in this, I was expecting app directory:

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

解决方案

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.

这篇关于将Android Studio项目从git导入Android Studio(Gradle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆