I have two projects, A and B, and would like to share some code between them via a library project, C. What is the proper way to do this such that:
I'm fairly new to Android Studio and I've been running into all sorts of issues here. I really just want to use source code that is located outside the project root. Thanks!
This sounds like the question asked (and answered) here .
To sum up Scott Barta's answer:
settings.gradle:
include ':module-custom-lib' project(':module-custom-lib').projectDir = new File(settingsDir, '../../../libraryProject/workspace/projectSrc')
A's and B's build.gradle:
dependencies { compile project(':module-custom-lib') }
So, assuming a file structure like this:
+-- AndroidStudioProjects
| +-- CoreLibs
| +-- app (empty)
| +-- myJavaCoreLib
| +-- anotherJavaCoreLib
| +-- AndroidApp1
| +-- app
| +-- AndroidApp2
| +-- app
| +-- AndroidApp3
| +-- app
...the code would be:
settings.gradle:
include ':coreLib'
project(':coreLib').projectDir = new File(settingsDir, '../CoreLibs/myJavaCoreLib')
build.gradle in AndroidApp[1, 2 and 3] (your A's and B's) :
compile project(':coreLib')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.