Java: how to distribute common application / UI code among multiple applications

I have several applications that differ mainly in resources. I am currently copying the code for each application. This can be problematic. Example: fixing a mistake in one and forgetting to update the rest.

I don’t think that creating a JAR is suitable for this situation, as these are application-specific user interface classes (actually activity classes in Android), including the actual application launch code.

Perhaps these source files can be included in several packages, but then I have a problem that each file indicates a specific package name in the first line.

Most of the code is related to UI and Activity processing. (The actual shared code is already in the library). A similar question is posted here . Are there any elegant solutions for this situation?

+3
source share
3 answers

I solved this by going into Android Library projects. (Unsure of the details, perhaps these are ultimately banks). More details ... here , in particular, the section "Setting up the library project". I basically put all activity classes (except the initial one) into the library.

For true non-UI code, JARs seem to be the way to go.

+2
source

. , .

+6

I agree with artbristol.

I also recommend using Maven and:

  • release shared banks to Maven corporate repository
  • declare dependency on specific versions of these jar artifacts

Similarly, you do not break applications if you make some incompatible changes.

+1
source

All Articles