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

查看:40
本文介绍了将 Android Studio 项目从 git 导入到 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 只包含应用程序目录,这是故意的.至于什么原因我不知道.尝试克隆 git repo 时,Android Studio 不知道如何处理.Android Studio 中一个非常烦人的缺陷.

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.

我的 .gitignore 中应该有什么用于 Android Studio 项目?

我有一个包含以下形式的项目的远程 git repo:

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

如您所见,git repo 包含 /app 目录.

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

然后我尝试通过 Check out project from Version Control 并选择 git 来导入它:

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

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

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

接下来我按 Yes 因为 git 没有克隆整个项目,而只是克隆了必要的源文件:

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

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

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:

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

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:

结果是这样,我期待的是 app 目录:

Results in this, I was expecting app directory:

文件结构(如您所见,fela 丢失了很多文件,这是我选择从现有源创建项目时,MyApplication 是在 Android Studio 中创建的应用程序示例):

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

推荐答案

当查看新创建项目的 .gitignore 文件时,答案很明显.build.gradle 文件并且应该包含在推送到远程存储库中.

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.

所以在我的问题中制作回购的人做错了..gitignore 文件包括:

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天全站免登陆