Android Studio,如何添加我自己的git仓库作为库项目(子模块)? [英] Android Studio, how to add my own git repository as a library project(sub module)?
问题描述
我只想知道如何在Android Studio中创建一个子模块,就像我们在Eclipse中通过egit插件一样,以及如何将其推送到全新的Git存储库,实际上这个子模块实际上是我的图书馆项目。
我也有同样的情况,我不得不开发一个图书馆和应用程序并行。
为此,您可以使用android库项目作为应用程序项目的git子模块,这样就可以管理应用程序项目和库项目。所以这里是我的解决方案:
步骤1:创建一个Android库项目。
它类似于创建正常的应用程序项目。只需浏览这个Google文档:
步骤4:将您的库代码推送到git存储库
步骤5:现在创建您的Android应用程序项目
步骤6:添加项目到版本控制系统(VCS)
步骤7:从底部sion控制菜单,将所有Unversioned文件添加到VCS
步骤8:从android studio项目终端添加git子模块使用命令
git子模块添加HHHH ://XXX@bitbucket.org/YYY/ZZZ.git
确保子模块保存位置文件夹名称与原始库项目名称不同,否则可能会产生冲突。
步骤9:您将收到'unregisterd vcs root detected'的消息。点击添加根
now您可以在Android工作室的右下角看到多个git存储库。
步骤10:goto文件菜单 - 项目结构
步骤11:点击左上角的+
步骤12:选择导入渐变项目
步骤15:同步
步骤16:现在在应用程序项目builg.gradle文件中添加
code>编译项目(':lib-name')
p>
步骤17:gradle sync&新新旗新新新旗新新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新旗新新200新200新200新200新200新200新新旗新新旗200 200新新200新200新200新200新新200新200新新200新新旗200新新200新200新新200新200新新200新200新新200新200新新200新200新新旗200新新新200新200新新200新200新新200新200新新200新200新新200新200新新200新200新新200新200新新200新新200新200人新200新新200新200人新200新新200新200人200 200现在你可以在应用程序和图书馆上并行开发。更好地为应用程序保留图书馆的单独分支,以免与其他应用程序使用冲突,如果库代码更改可以在其他项目中使用,也可以向库的主分支发送PR请求。
快乐编码:)
我已将此作为我的博客发布: I am new to Android Studio, Right now I have create a project and added a module in it as a library project but when i push the project to Git the library project gets also added to the repository instead in other new Git repository. I just want to know that how can i create a sub module in Android Studio like we do in Eclipse via egit plugin, and how to push it to a completely new Git repository, practically this sub module would actually be my library project. i also had the same situation where i had to develop a library and the application in parallel.
For this you can use android library project as git submodule to your application project, in that way you can manage both your application project and the library project.So here is my solution: Step 1: create an android library project. its similar to creating normal application project. just go through this google doc : https://developer.android.com/studio/projects/android-library.html step 2: create a repository for the library project in git (GitHub/BitBucket) step 3: add the library codes to the version control system (VCS) step 4: push your library codes to the git repository Step 5: now create your Android application project Step 6: Add the project to version control system (VCS) Step 7: From the bottom version control menu, add all the Unversioned Files to the VCS Step 8: From android studio project terminal add git sub-module using command Step 9: You will get a message for 'unregisterd vcs root detected'. click on add root now you can see multiple git repositories at the right bottom of the android studio Step 10: goto file menu — project structure Step 11: click ‘+’ on left top Step 12: select ‘Import Gradle Project’ Step 13: select the sub-module folder Step 14: give the actual sub-module project name Step 15: Sync Step 16: Now in the application project builg.gradle file add within the dependencies section Step 17: gradle sync & build project Now you have an application project in git, which uses a library which is added to it as a submodule in git. Now you can develop on the application and on the library parallelly. Its better to keep a separate branch of the library for an application so as not to conflict with other application usage, and if the library code changes can be used in other projects also you can make a PR request to the main branch of the library. Happy Coding :) I have published this as my blog:
https://medium.com/@deepakpk/how-to-add-a-git-android-library-project-as-a-sub-module-c713a653ab1f#.mt6dlng5n 这篇关于Android Studio,如何添加我自己的git仓库作为库项目(子模块)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
https: //medium.com/cn/developer/git submodule add HHHH://XXX@bitbucket.org/YYY/ZZZ.git
make sure the sub module save location folder name is different than the original library project name, else you might get conflicts.
compile project(‘:lib-name’)