如何在不复制 Android Studio 上的库项目的情况下进行引用? [英] How to reference without copying a library project on Android Studio?
问题描述
是的,我可以在任何地方学习如何从将复制库项目的项目制作模块.但这并不好,因为必须在使用它的每个项目上复制库项目中的更改.那么,如何以动态方式从项目外部的文件夹中引用它?
Yes, everywhere I can learn how to make a module from a project that will copy the library project. But that's no good, since a change in the library project would have to be replicated on every project that uses it. So, how can I reference it from a folder that's outside the project in a dynamic way?
推荐答案
明白了:在您的项目中,进入 settings.gradle 并声明如下内容:<代码>包括 ':LibReferenceName'project(':LibReferenceName').projectDir = new File(settingsDir, '../relativePath/toThe/libraryModule/fromTheProject')
Got it:
In your project, go in settings.gradle and declare something like this:
include ':LibReferenceName'
project(':LibReferenceName').projectDir = new File(settingsDir, '../relativePath/toThe/libraryModule/fromTheProject')
在需要库的模块中,在它的 build.gradle 中包含这样的内容:<代码>编译项目(路径:':LibReferenceName')
And at the modules that requires the library, include something like this in the build.gradle of it:
compile project(path: ':LibReferenceName')
你也可以不使用settingsDir而只放项目的绝对路径.
You can also not use settingsDir and just put the absolute path of the project.
这篇关于如何在不复制 Android Studio 上的库项目的情况下进行引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!