问题描述
我选择文件&gt创建Android Studio中(目前0.5.2)库项目;新建项目...> 标记此项目为一库
。
我有我想依赖添加到该库项目其他两个非库项目。
I have two other non-library projects that I would like to add a dependency to this library project.
-My Library
-Project 1 (depends on My Library)
-Project 2 (depends on My Library)
我的目标是让每个项目独立,避免重复模块/ code。这怎么可能没有库模块复制到其他项目呢?
My goal is to keep each project independent and avoid duplicating modules/code. How can this be done without copying the library module into the other projects?
更新:
Android的工作室0.6.0允许您导入模块,虽然,这只是复制模块源到项目。
Update:Android Studio 0.6.0 allows you to Import a module, though, this simply copies the module source into the Project.
推荐答案
您也可以参考图书馆使用项目()。PROJECTDIR物业项目文件夹之外。如果外部库是相对于你的项目像这样
You can also refer to a library outside of your project folder using the project().projectDir property. If your external library is relative to your project like so
- MyLibrary
- library
- MyProject
- app
在MyProject的/ settings.gradle
in MyProject/settings.gradle
include ':library'
project(':library').projectDir = new File(settingsDir, '../MyLibrary/library')
在MyProject的/应用/的build.gradle
in MyProject/app/build.gradle
dependencies {
compile project(':library')
}
这篇关于添加本地图书馆项目作为一个依赖于Android Studio中的多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!