Adding Android APK packages: Difference between revisions

From Variscite Wiki
(Created page with "== Android Build Process == The Android Build Cookbook offers code snippets to help you quickly implement some common build tasks. For additional instruction, please see the...")
 
No edit summary
Line 126: Line 126:
   # Build a static jar file.
   # Build a static jar file.
   include $(BUILD_STATIC_JAVA_LIBRARY)
   include $(BUILD_STATIC_JAVA_LIBRARY)
== Verify that it can build ==
$ mm
If build works, it should get built.
== Adding Apk to the Android Images ==
added the following instruction in device/variscite/imx6/var_mx6.mk :
PRODUCT_PACKAGES += \
LocalModuleName
*Note: You need to change LocalModuleName to your package name as per Android.mk.
For more details refer to: http://android.mk/

Revision as of 03:08, 23 November 2018

Android Build Process

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. Change to Android top level directory.

$ cd /
$ source build/envsetup.sh
$ lunch var_mx6-eng
or
$ lunch var_mx6-user

Note: var_mx6-user creates a production version of Android. var_mx6-eng creates an engineering version of Android. Development mode enable and development tools are available on target. Create your folder containing source code

$ mkdir -p //packages/app/<_your_app_folder_>
  • Note: Please change <_your_app_folder_> to some meaning ful package name.

Building a simple APK

Snippet:

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

Snippet:

 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)


Verify that it can build

$ mm

If build works, it should get built.

Adding Apk to the Android Images

added the following instruction in device/variscite/imx6/var_mx6.mk : PRODUCT_PACKAGES += \ LocalModuleName

  • Note: You need to change LocalModuleName to your package name as per Android.mk.

For more details refer to: http://android.mk/