I am building some components into an AOSP build and I would like them to share some Java code. Currently, I am adding two pieces:
- System APK (for some new services)
- Java library for host machines (client to interact with those services from apps)
There is some common code between the two that I would like to put in a shared "common" module, but I can't figure out the best way to include it? My first inclination was to do the following for each:
- Common = BUILD_STATIC_JAVA_LIBRARY
- Client Library = BUILD_HOST_JAVA_LIBRARY
- Includes the common under LOCAL_STATIC_JAVA_LIBRARIES
- APK = BUILD_PACKAGE
- Includes the common under LOCAL_STATIC_JAVA_LIBRARIES
The problem that I ran into is that BUILD_STATIC_JAVA_LIBRARY doesn't seem to feed nicely into BUILD_HOST_JAVA_LIBRARY as a dependency. It claims "no rule to make target" since javalib.jar doesn't exist for common (it builds a classes.jack file instead). If I change BUILD_HOST_JAVA_LIBRARY into BUILD_STATIC_JAVA_LIBRARY, everything compiles but I have no viable product in out/ that I can distribute (the code stays as classes.jack in intermediates).
Another idea I had was to change BUILD_STATIC_JAVA_LIBRARY into BUILD_JAVA_LIBRARY. However, I don't want the common code to be copied onto the target (no reason since it's built into the System APK as well).
Can anyone advise me on a proper technique for building the common code module that can be included by both an APK package and host library? Or perhaps a better way to deploy
Cheers,
--
Dave Smith, PE
@devunwired