platform_build/core
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
..
combo am 38158161: am 3343b27c: x86: The default ATOM BSP flags need to be in sync with the NDK ABI 2011-12-12 15:39:05 -08:00
tasks Restrict vendor modules to help AOSP product distribution. 2011-12-12 14:17:55 -08:00
Makefile SDK: pass $HOST_OUT variable to atree. 2011-11-15 16:32:42 -08:00
apicheck_msg_current.txt Current.xml and friends are now .txt instead. 2011-04-08 15:03:48 -07:00
apicheck_msg_last.txt auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
armelf.x auto import from //branches/cupcake/...@137873 2009-03-11 12:11:54 -07:00
armelf.xsc auto import from //branches/cupcake/...@137873 2009-03-11 12:11:54 -07:00
armelflib.x auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
base_rules.mk Merge "Allow to build Java module from mere static Java libraries." 2011-12-13 09:06:08 -08:00
binary.mk Use LOCAL_REQUIRED_MODULES to add dependency of installed shared libraries 2011-09-15 14:05:49 -07:00
build-system.html Remove the simulator target from all makefiles. 2011-07-11 23:51:37 -07:00
build_id.mk Restore AOSP-specific pseudo-version-numbers. 2011-11-22 12:21:00 -08:00
checktree auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
cleanbuild.mk New PRODUCT_AAPT_PREF_CONFIG. 2011-10-14 19:37:57 -07:00
cleanspec.mk Brian's vendor/ change requires a clean build. 2010-09-19 12:04:23 -04:00
clear_vars.mk Restrict vendor modules to help AOSP product distribution. 2011-12-12 14:17:55 -08:00
config.mk Move the prebuilt NDKs to their own git project prebuilts/ndk/. 2011-11-29 11:20:16 -08:00
copy_headers.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
definitions.mk Support to build static Java library with Android resource 2011-12-14 16:04:59 -08:00
device.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
dex_preopt.mk Updated dex-preopt BOOTCLASSPATH with values from init.rc 2011-09-06 13:04:36 -07:00
distdir.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
droiddoc.mk am f0d2a546: Merge 78e7f1f0 2011-06-07 18:20:30 -07:00
dumpvar.mk am 0cd997ff: am 8af0efd6: Improve handling of absolute paths in out directory 2011-12-06 22:53:45 -08:00
dynamic_binary.mk Refactor Stripper. Allow a stripper other than SOSLIM to be specified 2011-07-07 03:45:56 +02:00
envsetup.mk am 78b68045: am ffe03c98: Set OUT_DIR based on a common base path 2011-12-06 22:53:44 -08:00
executable.mk build: remove prelinker build build system 2011-03-12 14:59:46 -08:00
filter_symbols.sh auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
find-jdk-tools-jar.sh Merge from AOSP 2011-11-11 16:03:56 -08:00
help.mk make help: prints a handy list of useful targets 2010-10-28 15:40:06 -04:00
host_executable.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
host_java_library.mk Add LOCAL_JARJAR_RULES support for BUILD_HOST_JAVA_LIBRARY 2011-01-26 15:13:42 -08:00
host_native_test.mk Use the host STL for host native test. 2011-06-22 16:01:48 -07:00
host_prebuilt.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
host_shared_library.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
host_static_library.mk Make the host static library build rule know about 2009-10-15 16:28:56 -07:00
java.mk Allow to build Java module from mere static Java libraries. 2011-12-12 17:52:03 -08:00
java_library.mk Support to build static Java library with Android resource 2011-12-14 16:04:59 -08:00
legacy_prebuilts.mk Avoid loading all CA certs into Zygote memory, lazily load instead (1 of 3) 2011-04-29 00:48:44 -07:00
main.mk Build fix - include sdk/lint in build. 2011-11-28 15:05:31 -08:00
multi_prebuilt.mk allow setting LOCAL_STRIP_MODULE on multi_prebuilts 2011-09-06 10:31:37 -07:00
native_test.mk Add $(LOCAL_MODULE) as part of the installed path. 2010-07-26 16:25:55 -07:00
node_fns.mk fix makefile inheritance system 2010-02-18 12:23:35 -08:00
notice_files.mk build speedup: Do not use shell 'find' function to look for NOTICE files. 2011-03-29 14:27:27 +02:00
package.mk am b3e6fa5e: Merge "new LOCAL_DEX_PREOPT option "nostripping"" into ics-mr0 2011-10-27 04:04:50 +00:00
pathmap.mk Add the support libraries to the platform documentation (build). 2011-11-17 15:13:56 -08:00
phony_package.mk core: Make fake packages have real installed files for proper dependencies 2010-09-27 17:37:59 -07:00
prebuilt.mk sign non-PRESIGNED prebuilt apks 2011-10-05 09:49:24 -07:00
process_wrapper.sh auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
process_wrapper_gdb.cmds auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
process_wrapper_gdb.sh auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
product.mk Restrict vendor modules to help AOSP product distribution. 2011-12-12 14:17:55 -08:00
product_config.mk am a0f464a8: New PRODUCT_AAPT_PREF_CONFIG. 2011-10-17 11:31:38 -07:00
proguard.flags Make ProGuard keep necessary members for serializable classes 2010-08-11 08:24:46 +08:00
proguard_tests.flags Fix and enable proguard on packages. 2010-02-11 13:41:10 -08:00
raw_executable.mk Support to build native libraries with prebuilt NDK 2010-07-13 16:29:18 -07:00
raw_static_library.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
root.mk auto import from //depot/cupcake/@135843 2009-03-03 19:28:42 -08:00
shared_library.mk Put the NDK library paths ahead of TARGET_GLOBAL_LD_DIRS 2011-07-20 15:42:53 -07:00
static_java_library.mk Support to build static Java library with Android resource 2011-12-14 16:04:59 -08:00
static_library.mk Support to build native libraries with prebuilt NDK 2010-07-13 16:29:18 -07:00
user_tags.mk Remove last reference to layoutopt. 2011-10-26 17:15:11 -07:00
version_defaults.mk Did I say 4.1? Oh well what I *really* meant was 4.0.3, of course. 2011-12-07 10:30:19 -08:00