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

相关文章

Android实现打开本地pdf文件的两种方式

《Android实现打开本地pdf文件的两种方式》在现代应用中,PDF格式因其跨平台、稳定性好、展示内容一致等特点,在Android平台上,如何高效地打开本地PDF文件,不仅关系到用户体验,也直接影响... 目录一、项目概述二、相关知识2.1 PDF文件基本概述2.2 android 文件访问与存储权限2.

Android Studio 配置国内镜像源的实现步骤

《AndroidStudio配置国内镜像源的实现步骤》本文主要介绍了AndroidStudio配置国内镜像源的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、修改 hosts,解决 SDK 下载失败的问题二、修改 gradle 地址,解决 gradle

在Android平台上实现消息推送功能

《在Android平台上实现消息推送功能》随着移动互联网应用的飞速发展,消息推送已成为移动应用中不可或缺的功能,在Android平台上,实现消息推送涉及到服务端的消息发送、客户端的消息接收、通知渠道(... 目录一、项目概述二、相关知识介绍2.1 消息推送的基本原理2.2 Firebase Cloud Me

Android中Dialog的使用详解

《Android中Dialog的使用详解》Dialog(对话框)是Android中常用的UI组件,用于临时显示重要信息或获取用户输入,本文给大家介绍Android中Dialog的使用,感兴趣的朋友一起... 目录android中Dialog的使用详解1. 基本Dialog类型1.1 AlertDialog(

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

IDEA中Git版本回退的两种实现方案

《IDEA中Git版本回退的两种实现方案》作为开发者,代码版本回退是日常高频操作,IntelliJIDEA集成了强大的Git工具链,但面对reset和revert两种核心回退方案,许多开发者仍存在选择... 目录一、版本回退前置知识二、Reset方案:整体改写历史1、IDEA图形化操作(推荐)1.1、查看提

Android自定义Scrollbar的两种实现方式

《Android自定义Scrollbar的两种实现方式》本文介绍两种实现自定义滚动条的方法,分别通过ItemDecoration方案和独立View方案实现滚动条定制化,文章通过代码示例讲解的非常详细,... 目录方案一:ItemDecoration实现(推荐用于RecyclerView)实现原理完整代码实现

Android App安装列表获取方法(实践方案)

《AndroidApp安装列表获取方法(实践方案)》文章介绍了Android11及以上版本获取应用列表的方案调整,包括权限配置、白名单配置和action配置三种方式,并提供了相应的Java和Kotl... 目录前言实现方案         方案概述一、 androidManifest 三种配置方式

Android WebView无法加载H5页面的常见问题和解决方法

《AndroidWebView无法加载H5页面的常见问题和解决方法》AndroidWebView是一种视图组件,使得Android应用能够显示网页内容,它基于Chromium,具备现代浏览器的许多功... 目录1. WebView 简介2. 常见问题3. 网络权限设置4. 启用 JavaScript5. D

Android如何获取当前CPU频率和占用率

《Android如何获取当前CPU频率和占用率》最近在优化App的性能,需要获取当前CPU视频频率和占用率,所以本文小编就来和大家总结一下如何在Android中获取当前CPU频率和占用率吧... 最近在优化 App 的性能,需要获取当前 CPU视频频率和占用率,通过查询资料,大致思路如下:目前没有标准的