I need use the class SharedClass.java
in two projects: ProjectA and ProjectB, and if I change the code of SharedClass
, it needs to change in the other project too.
Asked
Active
Viewed 737 times
0

Cœur
- 37,241
- 25
- 195
- 267

user2022323
- 35
- 7
-
2Make a library project containing this classes – Krish Apr 16 '16 at 20:48
-
And what is the next step? – user2022323 Apr 16 '16 at 21:17
-
refer this lib project in your main applications – Krish Apr 16 '16 at 21:18
1 Answers
0
One option would be creating a library project or module, where you can provide all shared code, and include that in both projects.
Another option is adding an external source folder containing the shared classes to your projects, by adding it to the srcDirs
in your build.gradle files:
android {
...
sourceSets {
main.java.srcDirs += '../../path/to/shared/code'
}
}

Floern
- 33,559
- 24
- 104
- 119