本文主要是介绍git android studio project,將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 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只包含app目錄,這是故意的。出於什么原因我不知道。當試圖克隆git repo時,Android Studio不知道如何處理它。 Android Studio中一個非常惱人的缺陷。
對於Android Studio項目,我的.gitignore應該是什么?
I have a remote git repo containing the project in the form:
我有一個遠程git倉庫包含以下形式的項目:
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:
然后我嘗試通過從Version Control中檢出項目導入它並選擇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:
下一部分我按是,因為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:
如果我選擇從現有源創建項目,我會遇到以下問題:
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中創建的應用程序的示例):
3 个解决方案
#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.
查看新創建的項目的.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.
如圖所示,應該將更多文件上傳到遠程倉庫。
#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.
如果您的項目顯示錯誤,例如項目'xxxxxxx-xx'不是基於Gradle的項目,請檢查此鏈接。我希望它有所幫助。此鏈接可能涵蓋您可能遇到的問題。讓我知道進展情況。
这篇关于git android studio project,將Android Studio項目從git導入Android Studio(Gradle)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!