Gaurav Mathur | 6ff7572 | 2009-05-18 15:26:51 -0700 | [diff] [blame] | 1 | page.title=<my_page_title> |
| 2 | pdk.version=<current_PDK_version> |
| 3 | @jd:body |
| 4 | |
| 5 | <a name="toc"/> |
| 6 | <div style="padding:10px"> |
| 7 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#Building_a_simple_APK">Building a simple APK</a><br> |
| 8 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#Building_a_APK_that_depends_on_a">Building a APK that depends on a static .jar file</a><br> |
| 9 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#Building_a_APK_that_should_be_si">Building a APK that should be signed with the platform key</a><br> |
| 10 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#Building_a_APK_that_should_be_si">Building a APK that should be signed with a specific vendor key</a><br> |
| 11 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#Adding_a_prebuilt_APK">Adding a prebuilt APK</a><br> |
| 12 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#Adding_a_Static_Java_Library">Adding a Static Java Library</a><br> |
| 13 | <a href="http://wiki.corp.google.com/twiki/bin/view/Main/AndroidBuildCookbook#LOCAL_MODULE_TAGS">Using LOCAL_MODULE_TAGS</a><br> |
| 14 | </div> |
| 15 | |
| 16 | <p>The Android Build Cookbook offers code snippets to help you quickly implement some common build tasks. For additional instruction, please see the other build documents in this section.</p> |
| 17 | <h2><a name="Building_a_simple_APK" id="Building_a_simple_APK"></a>Building a simple APK</h2> |
| 18 | <pre> |
| 19 | LOCAL_PATH := $(call my-dir) |
| 20 | include $(CLEAR_VARS) |
| 21 | |
| 22 | # Build all java files in the java subdirectory |
| 23 | LOCAL_SRC_FILES := $(call all-subdir-java-files) |
| 24 | |
| 25 | # Name of the APK to build |
| 26 | LOCAL_PACKAGE_NAME := LocalPackage |
| 27 | |
| 28 | # Tell it to build an APK |
| 29 | include $(BUILD_PACKAGE) |
| 30 | </pre> |
| 31 | <h2><a name="Building_a_APK_that_depends_on_a" id="Building_a_APK_that_depends_on_a"></a>Building a APK that depends on a static .jar file</h2> |
| 32 | <pre> |
| 33 | LOCAL_PATH := $(call my-dir) |
| 34 | include $(CLEAR_VARS) |
| 35 | |
| 36 | # List of static libraries to include in the package |
| 37 | LOCAL_STATIC_JAVA_LIBRARIES := static-library |
| 38 | |
| 39 | # Build all java files in the java subdirectory |
| 40 | LOCAL_SRC_FILES := $(call all-subdir-java-files) |
| 41 | |
| 42 | # Name of the APK to build |
| 43 | LOCAL_PACKAGE_NAME := LocalPackage |
| 44 | |
| 45 | # Tell it to build an APK |
| 46 | include $(BUILD_PACKAGE) |
| 47 | </pre> |
| 48 | <h2><a name="Building_a_APK_that_should_be_si" id="Building_a_APK_that_should_be_si">Building a APK that should be signed with the platform key</a></h2> |
| 49 | <pre> |
| 50 | LOCAL_PATH := $(call my-dir) |
| 51 | include $(CLEAR_VARS) |
| 52 | |
| 53 | # Build all java files in the java subdirectory |
| 54 | LOCAL_SRC_FILES := $(call all-subdir-java-files) |
| 55 | |
| 56 | # Name of the APK to build |
| 57 | LOCAL_PACKAGE_NAME := LocalPackage |
| 58 | |
| 59 | LOCAL_CERTIFICATE := platform |
| 60 | |
| 61 | # Tell it to build an APK |
| 62 | include $(BUILD_PACKAGE) |
| 63 | </pre> |
| 64 | <h2>Building a APK that should be signed with a specific vendor key</h2> |
| 65 | <pre> |
| 66 | LOCAL_PATH := $(call my-dir) |
| 67 | include $(CLEAR_VARS) |
| 68 | |
| 69 | # Build all java files in the java subdirectory |
| 70 | LOCAL_SRC_FILES := $(call all-subdir-java-files) |
| 71 | |
| 72 | # Name of the APK to build |
| 73 | LOCAL_PACKAGE_NAME := LocalPackage |
| 74 | |
| 75 | LOCAL_CERTIFICATE := vendor/example/certs/app |
| 76 | |
| 77 | # Tell it to build an APK |
| 78 | include $(BUILD_PACKAGE) |
| 79 | </pre> |
| 80 | <h2><a name="Adding_a_prebuilt_APK" id="Adding_a_prebuilt_APK"></a>Adding a prebuilt APK</h2> |
| 81 | <pre> |
| 82 | LOCAL_PATH := $(call my-dir) |
| 83 | include $(CLEAR_VARS) |
| 84 | |
| 85 | # Module name should match apk name to be installed. |
| 86 | LOCAL_MODULE := LocalModuleName |
| 87 | LOCAL_SRC_FILES := $(LOCAL_MODULE).apk |
| 88 | LOCAL_MODULE_CLASS := APPS |
| 89 | LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) |
| 90 | |
| 91 | include $(BUILD_PREBUILT) |
| 92 | </pre> |
| 93 | <h2><a name="Adding_a_Static_Java_Library" id="Adding_a_Static_Java_Library"></a>Adding a Static Java Library</h2> |
| 94 | <pre> |
| 95 | LOCAL_PATH := $(call my-dir) |
| 96 | include $(CLEAR_VARS) |
| 97 | |
| 98 | # Build all java files in the java subdirectory |
| 99 | LOCAL_SRC_FILES := $(call all-subdir-java-files) |
| 100 | |
| 101 | # Any libraries that this library depends on |
| 102 | LOCAL_JAVA_LIBRARIES := android.test.runner |
| 103 | |
| 104 | # The name of the jar file to create |
| 105 | LOCAL_MODULE := sample |
| 106 | |
| 107 | # Build a static jar file. |
| 108 | include $(BUILD_STATIC_JAVA_LIBRARY) |
| 109 | </pre> |
| 110 | <h2><a name="Random_other_build_tidbits" id="Random_other_build_tidbits"></a>Random other build tidbits</h2> |
| 111 | <h3><a name="LOCAL_MODULE_TAGS" id="LOCAL_MODULE_TAGS"></a>LOCAL_MODULE_TAGS</h3> |
| 112 | <p>This variable controls what build flavors the package gets included in. For example:</p> |
| 113 | <ul type="disc"> |
| 114 | <li>user - means include this in user/userdebug builds</li> |
| 115 | <li>eng - means include this in eng builds</li> |
| 116 | <li>tests - means the target is a testing target and makes it available for tests</li> |
| 117 | <li>optional - don't include this</li> |
| 118 | </ul> |