简体   繁体   English

如何在Android Studio中的项目中软导入模块?

[英]How to soft import a module in a project in Android Studio?

I have 2 projects, MyLibrary, and MyProject. 我有2个项目,MyLibrary和MyProject。 They each have their own repository. 他们每个人都有自己的存储库。 I want to develop and debug MyProject and MyLibrary together inside the same Android Studio window. 我想在同一个Android Studio窗口中一起开发和调试MyProject和MyLibrary。 I want to be able to add breakpoints inside MyLibrary and MyProject codes while I run my app. 我希望能够在运行应用程序时在MyLibrary和MyProject代码中添加断点。 I tried using the Import module in Android Studio and it actually copied MyLibrary into MyProject repo. 我尝试在Android Studio中使用“导入”模块,并且实际上将MyLibrary复制到MyProject存储库中。 Is there any way I can just reference the MyLibrary as a directory path inside MyProject? 有什么办法可以引用MyLibrary作为MyProject中的目录路径? So that I can commit my codes in their own repository? 这样我就可以在自己的存储库中提交代码了?

Let's say my paths are: 假设我的路径是:

MyLibrary - /Users/me/repo/MyLibrary MyLibrary-/ Users / me / repo / MyLibrary

MyProject - /Users/me/repo/MyProject MyProject-/ Users / me / repo / MyProject

Thanks 谢谢

Add a module in your project repo, then configure its sourceSets (java, resources etc.) in module's build.gradle file to point to your library repo. 在项目仓库中添加一个模块,然后在模块的build.gradle文件中配置其sourceSets(java,资源等)以指向您的库仓库。

See this . 看到这个 And then add a compile dependency for your prjects. 然后为您的项目添加一个编译依赖项。 perform a gradle sync and you should be good to go. 执行gradle同步,您应该一切顺利。

Android sourceSets配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM