From 6ff7572fd50f148e96d87ecb347f138f69ea810d Mon Sep 17 00:00:00 2001 From: Gaurav Mathur Date: Mon, 18 May 2009 15:26:51 -0700 Subject: [PATCH] AI 148967: Cloned from CL 148932 by 'g4 patch'. Original change by dwarren@dwarren-pdk on 2009/05/15 16:17:05. Adding Build Cookbook to PDK. Automated import of CL 148967 --- pdk/docs/guide/build_cookbook.jd | 118 +++++++++++++++++++++++++++++++ pdk/docs/guide/pdk_toc.cs | 1 + 2 files changed, 119 insertions(+) create mode 100755 pdk/docs/guide/build_cookbook.jd diff --git a/pdk/docs/guide/build_cookbook.jd b/pdk/docs/guide/build_cookbook.jd new file mode 100755 index 000000000..ad5f8b89f --- /dev/null +++ b/pdk/docs/guide/build_cookbook.jd @@ -0,0 +1,118 @@ +page.title= +pdk.version= +@jd:body + + +
+Building a simple APK
+ Building a APK that depends on a static .jar file
+ Building a APK that should be signed with the platform key
+ Building a APK that should be signed with a specific vendor key
+ Adding a prebuilt APK
+ Adding a Static Java Library
+ Using LOCAL_MODULE_TAGS
+
+ +

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.

+

Building a simple APK

+
+  LOCAL_PATH := $(call my-dir)
+  include $(CLEAR_VARS)
+   
+  # Build all java files in the java subdirectory
+  LOCAL_SRC_FILES := $(call all-subdir-java-files)
+   
+  # Name of the APK to build
+  LOCAL_PACKAGE_NAME := LocalPackage
+   
+  # Tell it to build an APK
+  include $(BUILD_PACKAGE)
+
+

Building a APK that depends on a static .jar file

+
+  LOCAL_PATH := $(call my-dir)
+  include $(CLEAR_VARS)
+   
+  # List of static libraries to include in the package
+  LOCAL_STATIC_JAVA_LIBRARIES := static-library
+   
+  # Build all java files in the java subdirectory
+  LOCAL_SRC_FILES := $(call all-subdir-java-files)
+   
+  # Name of the APK to build
+  LOCAL_PACKAGE_NAME := LocalPackage
+   
+  # Tell it to build an APK
+  include $(BUILD_PACKAGE)
+
+

Building a APK that should be signed with the platform key

+
+  LOCAL_PATH := $(call my-dir)
+  include $(CLEAR_VARS)
+   
+  # Build all java files in the java subdirectory
+  LOCAL_SRC_FILES := $(call all-subdir-java-files)
+   
+  # Name of the APK to build
+  LOCAL_PACKAGE_NAME := LocalPackage
+   
+  LOCAL_CERTIFICATE := platform
+   
+  # Tell it to build an APK
+  include $(BUILD_PACKAGE)
+
+

Building a APK that should be signed with a specific vendor key

+
+  LOCAL_PATH := $(call my-dir)
+  include $(CLEAR_VARS)
+   
+  # Build all java files in the java subdirectory
+  LOCAL_SRC_FILES := $(call all-subdir-java-files)
+   
+  # Name of the APK to build
+  LOCAL_PACKAGE_NAME := LocalPackage
+   
+  LOCAL_CERTIFICATE := vendor/example/certs/app
+   
+  # Tell it to build an APK
+  include $(BUILD_PACKAGE)
+
+

Adding a prebuilt APK

+
+  LOCAL_PATH := $(call my-dir)
+  include $(CLEAR_VARS)
+   
+  # Module name should match apk name to be installed.
+  LOCAL_MODULE := LocalModuleName
+  LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
+  LOCAL_MODULE_CLASS := APPS
+  LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
+   
+  include $(BUILD_PREBUILT)
+
+

Adding a Static Java Library

+
+  LOCAL_PATH := $(call my-dir)
+  include $(CLEAR_VARS)
+   
+  # Build all java files in the java subdirectory
+  LOCAL_SRC_FILES := $(call all-subdir-java-files)
+   
+  # Any libraries that this library depends on
+  LOCAL_JAVA_LIBRARIES := android.test.runner
+   
+  # The name of the jar file to create
+  LOCAL_MODULE := sample
+   
+  # Build a static jar file.
+  include $(BUILD_STATIC_JAVA_LIBRARY)
+
+

Random other build tidbits

+

LOCAL_MODULE_TAGS

+

This variable controls what build flavors the package gets included in. For example:

+
    +
  • user - means include this in user/userdebug builds
  • +
  • eng - means include this in eng builds
  • +
  • tests - means the target is a testing target and makes it available for tests
  • +
  • optional - don't include this
  • +
diff --git a/pdk/docs/guide/pdk_toc.cs b/pdk/docs/guide/pdk_toc.cs index 44d94206c..ebc99577f 100644 --- a/pdk/docs/guide/pdk_toc.cs +++ b/pdk/docs/guide/pdk_toc.cs @@ -14,6 +14,7 @@ function nothing() {}
  • Bring up
  • Keymaps and Keyboard
  • Display Drivers
  • +
  • Build Cookbook