Adding Android APK packages: Difference between revisions
Line 19: | Line 19: | ||
$ lunch {{#var:ANDROID_MACHINE_NAME}}-user | $ lunch {{#var:ANDROID_MACHINE_NAME}}-user | ||
<span style="color:red">Note: </span> {{#var:ANDROID_MACHINE_NAME}}-userdebug creates a debuggable version of Android. | <span style="color:red">Note: </span> {{#var:ANDROID_MACHINE_NAME}}-userdebug creates a debuggable version of Android. | ||
{{#var:ANDROID_MACHINE_NAME}}-user creates an release production of Android. | {{#var:ANDROID_MACHINE_NAME}}-user: creates an release production of Android.<br> where development mode is enabled but some tools are not available on the target.<br> | ||
| | | | ||
$ source build/envsetup.sh | $ source build/envsetup.sh | ||
Line 25: | Line 25: | ||
or | or | ||
$ lunch {{#var:ANDROID_MACHINE_NAME}}-user | $ lunch {{#var:ANDROID_MACHINE_NAME}}-user | ||
<span style="color:red">Note: </span> {{#var:ANDROID_MACHINE_NAME}}-user creates an release production of Android. <br> | <span style="color:red">Note: </span> {{#var:ANDROID_MACHINE_NAME}}-user : creates an release production of Android. <br> where development mode is enabled but some tools are not available on the target.<br> | ||
{{#var:ANDROID_MACHINE_NAME}}-userdebug creates a debuggable version of Android.<br> Development mode enables and development tools are available on the target.<br> | {{#var:ANDROID_MACHINE_NAME}}-userdebug: creates a debuggable version of Android.<br> Development mode enables and development tools are available on the target.<br> | ||
|}} | |}} | ||
<br> | <br> |
Latest revision as of 19:43, 21 September 2023
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 ~/var_imx-o8.1.0_1.3.0_8m/android_build $ source build/envsetup.sh $ lunch dart_mx8m-userdebug or $ lunch dart_mx8m-user
Note: dart_mx8m-user : creates an release production of Android.
where development mode is enabled but some tools are not available on the target.
dart_mx8m-userdebug: creates a debuggable version of Android.
Development mode enables and development tools are available on the target.
Create your folder containing the source code:
$ mkdir -p ~/var_imx-o8.1.0_1.3.0_8m/android_build/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/imx8/dart_mx8m.mk:
PRODUCT_PACKAGES += \ LocalModuleName
- Note: You need to change LocalModuleName to your package name as per Android.mk.