将 Android Studio 项目从 git 导入到 Android Studio (Gradle)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30127943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Import Android Studio project from git into Android Studio (Gradle)
提问by Karl Morrison
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.
Android Studio .gitignore 只包含应用程序目录,这是故意的。至于什么原因我不知道。尝试克隆 git repo 时,Android Studio 不知道如何处理。Android Studio 中一个非常烦人的缺陷。
What should be in my .gitignore for an Android Studio project?
对于 Android Studio 项目,我的 .gitignore 中应该包含哪些内容?
I have a remote git repo containing the project in the form:
我有一个包含以下形式的项目的远程 git repo:
as you can see the git repo contains the /app
directory.
如您所见,git repo 包含该/app
目录。
I then try to import it via Check out project from Version Control
and select git
:
然后我尝试通过导入它Check out project from Version Control
并选择git
:
Everything works, the Test
is successful and then I click on Clone
:
一切正常,Test
成功,然后我点击Clone
:
The next part I press Yes
as git did not clone the entire project but just the essential source files:
我按下的下一部分Yes
git 没有克隆整个项目,而只是克隆了基本的源文件:
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
,所以我选择Gradle
并按Next
:
What am I supposed to do here, there are apparently gradle files on the net but which one am I supposed to use:
我应该在这里做什么,网上显然有 gradle 文件,但我应该使用哪一个:
Create project from existing sources
从现有源创建项目
If I choose Create project from existing sources
I get the following problem:
如果我选择,Create project from existing sources
我会遇到以下问题:
Results in this, I was expecting app
directory:
结果在这,我期待app
目录:
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):
文件结构(如您所见,fela 缺少很多文件,这是我选择从现有源创建项目时,MyApplication 是在 Android Studio 中创建的应用程序示例):
采纳答案by Karl Morrison
The answer is obvious when looking at the .gitignore
file of a newly created project. The build.gradle
file isand shouldbe included in the push to the remote repo.
查看.gitignore
新创建的项目的文件时,答案很明显。该build.gradle
文件是并且应该包含在推送到远程存储库中。
So the person who made the repo in my question is doing it wrong. The .gitignore
file includes:
所以在我的问题中制作回购的人做错了。该.gitignore
文件包括:
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
As seen, more files should of been uploaded to the remote repo.
正如所见,应该将更多文件上传到远程存储库。
回答by Danny Buonocore
Choose Existing Sources instead of Import
选择现有源而不是导入
回答by Roon13
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.
如果您的项目显示错误,The project 'xxxxxxx-xx' is not a Gradle-based project
请查看此链接。我希望它有帮助。此链接可能涵盖您可能遇到的问题。让我知道进展。