Go to file
Ying Wang 20e2083ea0 Support to build static Java library with Android resource
Bug: 5714516

The rationale behind this change:
- the library is compiled into a jar file, but its R class is generated
  making the constant not constant (static, not final static) (aapt
  option --non-constant-id). Also the jar file does not contain the R
  class.
- this allows the integer value to not be inlined in the compiled
  class files. Note that this prevents using switch statements.
- the main project use this jar file as a normal static library: it will
  add all the class files except the R.class.
- the main project uses the library res folder as a resource
  folder with lower priority than the main project (basically the
  main project is an overlay. This is accomplished using aapt's
  --auto-add-overlay to handle resources only in the main project
  (which the normal overlay mechanism doesn't allow).
- the main project creates R classes in the main project's
  package but also in the library's package. This is done with
  aapt's --extra-packages which accept as many packages as
  needed, separated by a :.
- manifest merging is not done yet, so
  activities/services/permissions/etc... have to be manually declared in
  the main app.

To use a static library with Android resource in your app,
1. Add the library's resource dir to your app as an overlay:
LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs>
2. Set the proper aapt flags:
LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \
  --extra-packages <lib1_package_name>:<lib2_package_name>:...

Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 16:04:59 -08:00
core Support to build static Java library with Android resource 2011-12-14 16:04:59 -08:00
libs/host Cygwin fix: Use new #if HAVE_STAT_ST_MTIM 2010-11-01 15:53:45 -07:00
target Add boot property enabling ADBD over QEMU 2011-12-13 11:31:54 -08:00
tools Make java-event-log-tags.py create its output directory if it does not exist. 2011-12-13 10:56:33 -08:00
.gitignore add a .gitignore file to make git ignore *.pyc files 2010-01-22 10:23:45 -08:00
CleanSpec.mk Dev branch for ICS MR2. 2011-11-10 15:19:51 -08:00
buildspec.mk.default Remove the simulator target from all makefiles. 2011-07-11 23:51:37 -07:00
envsetup.sh Add support for building specific modules with mmm using the following syntax: 2011-11-30 12:40:19 -08:00