blob: ad5f8b89ffe4565f8c8716e1d20c8dea9dfcc9d0 [file] [log] [blame]
Gaurav Mathur6ff75722009-05-18 15:26:51 -07001page.title=<my_page_title>
2pdk.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 &nbsp;
22 # Build all java files in the java subdirectory
23 LOCAL_SRC_FILES := $(call all-subdir-java-files)
24 &nbsp;
25 # Name of the APK to build
26 LOCAL_PACKAGE_NAME := LocalPackage
27 &nbsp;
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 &nbsp;
36 # List of static libraries to include in the package
37 LOCAL_STATIC_JAVA_LIBRARIES := static-library
38 &nbsp;
39 # Build all java files in the java subdirectory
40 LOCAL_SRC_FILES := $(call all-subdir-java-files)
41 &nbsp;
42 # Name of the APK to build
43 LOCAL_PACKAGE_NAME := LocalPackage
44 &nbsp;
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 &nbsp;
53 # Build all java files in the java subdirectory
54 LOCAL_SRC_FILES := $(call all-subdir-java-files)
55 &nbsp;
56 # Name of the APK to build
57 LOCAL_PACKAGE_NAME := LocalPackage
58 &nbsp;
59 LOCAL_CERTIFICATE := platform
60 &nbsp;
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 &nbsp;
69 # Build all java files in the java subdirectory
70 LOCAL_SRC_FILES := $(call all-subdir-java-files)
71 &nbsp;
72 # Name of the APK to build
73 LOCAL_PACKAGE_NAME := LocalPackage
74 &nbsp;
75 LOCAL_CERTIFICATE := vendor/example/certs/app
76 &nbsp;
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 &nbsp;
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 &nbsp;
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 &nbsp;
98 # Build all java files in the java subdirectory
99 LOCAL_SRC_FILES := $(call all-subdir-java-files)
100 &nbsp;
101 # Any libraries that this library depends on
102 LOCAL_JAVA_LIBRARIES := android.test.runner
103 &nbsp;
104 # The name of the jar file to create
105 LOCAL_MODULE := sample
106 &nbsp;
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>