Adding Android APK packages: Difference between revisions
No edit summary |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- | --> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- | ||
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}}} <!-- | --> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}}} <!-- | ||
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_NXP_VERSION}} Adding Android APK to | --> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_NXP_VERSION}} Adding Android APK to AOSP Build}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__ | ||
== Android Build Process == | == 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. | 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. | Change to Android top-level directory. | ||
{{#ifeq: {{#var:ANDROID_NXP_VERSION}} | O8.0.0_1.0.0 | | {{#ifeq: {{#var:ANDROID_NXP_VERSION}} | O8.0.0_1.0.0 | | ||
$ cd {{#var:BUILD_FOLDER_ANDROID}} | $ cd {{#var:BUILD_FOLDER_ANDROID}} | ||
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. | <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. | {{#var:ANDROID_MACHINE_NAME}}-userdebug: creates a debuggable version of Android.<br> Development mode enables and development tools are available on the target.<br> | ||
|}} | |}} | ||
Create your folder containing source code | <br> | ||
<br> | |||
Create your folder containing the source code: | |||
{{#ifeq: {{#var:ANDROID_NXP_VERSION}} | O8.0.0_1.0.0 | | {{#ifeq: {{#var:ANDROID_NXP_VERSION}} | O8.0.0_1.0.0 | | ||
$ mkdir -p {{#var:BUILD_FOLDER_ANDROID}}/packages/app/<_your_app_folder_> | $ mkdir -p {{#var:BUILD_FOLDER_ANDROID}}/packages/app/<_your_app_folder_> |
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.