git android studio project,將Android Studio項目從git導入Android Studio(Gradle)

2023-12-15 12:59

本文主要是介绍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倉庫包含以下形式的項目:

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9DdE1kNy5wbmc=

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:

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9VRnJiWS5wbmc=

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

一切正常,測試成功,然后我點擊克隆:

fd920d5dd12d1e6a9ad03347f4934850.png

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

下一部分我按是,因為git沒有克隆整個項目,只是基本的源文件:

92c642b67400d29859467f5d3d08615b.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:

這是我迷失的部分,我猜我是通過Gradle創建項目的,所以我選擇Gradle並按Next:

d86c8be5bfe18ce39ae1005ddcf208a1.png

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

我應該在這里做什么,網上有明顯的gradle文件,但我應該使用哪一個:

ac119a2259debb8f67394a8c879b273f.png

Create project from existing sources

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

如果我選擇從現有源創建項目,我會遇到以下問題:

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9DTEtRTC5wbmc=

b3b46cf2339f3cfa6a090e1b48527981.png

06a2e46cd8abfbaa161c5a19e3a5fc21.png

Results in this, I was expecting app directory:

結果在這,我期待的app目錄:

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

文件結構(正如你所看到的,fela缺少很多文件,這是當我選擇從現有源創建項目時,MyApplication是在Android Studio中創建的應用程序的示例):

e55f39c89499adac4f209fd6a3d5f3d6.png

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)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/496532

相关文章

IDEA中新建/切换Git分支的实现步骤

《IDEA中新建/切换Git分支的实现步骤》本文主要介绍了IDEA中新建/切换Git分支的实现步骤,通过菜单创建新分支并选择是否切换,创建后在Git详情或右键Checkout中切换分支,感兴趣的可以了... 前提:项目已被Git托管1、点击上方栏Git->NewBrancjsh...2、输入新的分支的

一文详解Git中分支本地和远程删除的方法

《一文详解Git中分支本地和远程删除的方法》在使用Git进行版本控制的过程中,我们会创建多个分支来进行不同功能的开发,这就容易涉及到如何正确地删除本地分支和远程分支,下面我们就来看看相关的实现方法吧... 目录技术背景实现步骤删除本地分支删除远程www.chinasem.cn分支同步删除信息到其他机器示例步骤

Visual Studio 2022 编译C++20代码的图文步骤

《VisualStudio2022编译C++20代码的图文步骤》在VisualStudio中启用C++20import功能,需设置语言标准为ISOC++20,开启扫描源查找模块依赖及实验性标... 默认创建Visual Studio桌面控制台项目代码包含C++20的import方法。右键项目的属性:

Android DataBinding 与 MVVM使用详解

《AndroidDataBinding与MVVM使用详解》本文介绍AndroidDataBinding库,其通过绑定UI组件与数据源实现自动更新,支持双向绑定和逻辑运算,减少模板代码,结合MV... 目录一、DataBinding 核心概念二、配置与基础使用1. 启用 DataBinding 2. 基础布局

Android ViewBinding使用流程

《AndroidViewBinding使用流程》AndroidViewBinding是Jetpack组件,替代findViewById,提供类型安全、空安全和编译时检查,代码简洁且性能优化,相比Da... 目录一、核心概念二、ViewBinding优点三、使用流程1. 启用 ViewBinding (模块级

git stash命令基本用法详解

《gitstash命令基本用法详解》gitstash是Git中一个非常有用的命令,它可以临时保存当前工作区的修改,让你可以切换到其他分支或者处理其他任务,而不需要提交这些还未完成的修改,这篇文章主要... 目录一、基本用法1. 保存当前修改(包括暂存区和工作区的内容)2. 查看保存了哪些 stash3. 恢

Android学习总结之Java和kotlin区别超详细分析

《Android学习总结之Java和kotlin区别超详细分析》Java和Kotlin都是用于Android开发的编程语言,它们各自具有独特的特点和优势,:本文主要介绍Android学习总结之Ja... 目录一、空安全机制真题 1:Kotlin 如何解决 Java 的 NullPointerExceptio

IDEA实现回退提交的git代码(四种常见场景)

《IDEA实现回退提交的git代码(四种常见场景)》:本文主要介绍IDEA实现回退提交的git代码(四种常见场景),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.已提交commit,还未push到远端(Undo Commit)2.已提交commit并push到

idea中project的显示问题及解决

《idea中project的显示问题及解决》:本文主要介绍idea中project的显示问题及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录idea中project的显示问题清除配置重China编程新生成配置总结idea中project的显示问题新建空的pr

Android NDK版本迭代与FFmpeg交叉编译完全指南

《AndroidNDK版本迭代与FFmpeg交叉编译完全指南》在Android开发中,使用NDK进行原生代码开发是一项常见需求,特别是当我们需要集成FFmpeg这样的多媒体处理库时,本文将深入分析A... 目录一、android NDK版本迭代分界线二、FFmpeg交叉编译关键注意事项三、完整编译脚本示例四