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实现任意版本设置默认的锁屏壁纸和桌面壁纸(两张壁纸可不一致)

客户有些需求需要设置默认壁纸和锁屏壁纸  在默认情况下 这两个壁纸是相同的  如果需要默认的锁屏壁纸和桌面壁纸不一样 需要额外修改 Android13实现 替换默认桌面壁纸: 将图片文件替换frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.*  (注意不能是bmp格式) 替换默认锁屏壁纸: 将图片资源放入vendo

Android平台播放RTSP流的几种方案探究(VLC VS ExoPlayer VS SmartPlayer)

技术背景 好多开发者需要遴选Android平台RTSP直播播放器的时候,不知道如何选的好,本文针对常用的方案,做个大概的说明: 1. 使用VLC for Android VLC Media Player(VLC多媒体播放器),最初命名为VideoLAN客户端,是VideoLAN品牌产品,是VideoLAN计划的多媒体播放器。它支持众多音频与视频解码器及文件格式,并支持DVD影音光盘,VCD影

git使用的说明总结

Git使用说明 下载安装(下载地址) macOS: Git - Downloading macOS Windows: Git - Downloading Windows Linux/Unix: Git (git-scm.com) 创建新仓库 本地创建新仓库:创建新文件夹,进入文件夹目录,执行指令 git init ,用以创建新的git 克隆仓库 执行指令用以创建一个本地仓库的

如何在Visual Studio中调试.NET源码

今天偶然在看别人代码时,发现在他的代码里使用了Any判断List<T>是否为空。 我一般的做法是先判断是否为null,再判断Count。 看了一下Count的源码如下: 1 [__DynamicallyInvokable]2 public int Count3 {4 [__DynamicallyInvokable]5 get

android-opencv-jni

//------------------start opencv--------------------@Override public void onResume(){ super.onResume(); //通过OpenCV引擎服务加载并初始化OpenCV类库,所谓OpenCV引擎服务即是 //OpenCV_2.4.3.2_Manager_2.4_*.apk程序包,存

从状态管理到性能优化:全面解析 Android Compose

文章目录 引言一、Android Compose基本概念1.1 什么是Android Compose?1.2 Compose的优势1.3 如何在项目中使用Compose 二、Compose中的状态管理2.1 状态管理的重要性2.2 Compose中的状态和数据流2.3 使用State和MutableState处理状态2.4 通过ViewModel进行状态管理 三、Compose中的列表和滚动

沁恒CH32在MounRiver Studio上环境配置以及使用详细教程

目录 1.  RISC-V简介 2.  CPU架构现状 3.  MounRiver Studio软件下载 4.  MounRiver Studio软件安装 5.  MounRiver Studio软件介绍 6.  创建工程 7.  编译代码 1.  RISC-V简介         RISC就是精简指令集计算机(Reduced Instruction SetCom

git ssh key相关

step1、进入.ssh文件夹   (windows下 下载git客户端)   cd ~/.ssh(windows mkdir ~/.ssh) step2、配置name和email git config --global user.name "你的名称"git config --global user.email "你的邮箱" step3、生成key ssh-keygen

Android 10.0 mtk平板camera2横屏预览旋转90度横屏拍照图片旋转90度功能实现

1.前言 在10.0的系统rom定制化开发中,在进行一些平板等默认横屏的设备开发的过程中,需要在进入camera2的 时候,默认预览图像也是需要横屏显示的,在上一篇已经实现了横屏预览功能,然后发现横屏预览后,拍照保存的图片 依然是竖屏的,所以说同样需要将图片也保存为横屏图标了,所以就需要看下mtk的camera2的相关横屏保存图片功能, 如何实现实现横屏保存图片功能 如图所示: 2.mtk

android应用中res目录说明

Android应用的res目录是一个特殊的项目,该项目里存放了Android应用所用的全部资源,包括图片、字符串、颜色、尺寸、样式等,类似于web开发中的public目录,js、css、image、style。。。。 Android按照约定,将不同的资源放在不同的文件夹中,这样可以方便的让AAPT(即Android Asset Packaging Tool , 在SDK的build-tools目