0

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.

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

1 Answers1

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