Android 5.0 pre-fabricated APK method, android5.0 pre-fabricated apk
First, how do I preset the APK with source code into the system? // Cao haoyang's column
1) Under packages/apps, create a new folder with the name of the apk to be preset. The example is to preset an APK named Test.
2) copy the Source code of Test APK to the Test folder and delete the/bin and/gen directories.
3) create a file named Android. mk in the Test directory. The content is as follows:
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE_TAGS: = optional
LOCAL_SRC_FILES: = $ (call all-subdir-java-files)
LOCAL_PACKAGE_NAME: = Test
Include $ (BUILD_PACKAGE)
4) open the file device \ mediatek \ common \ device. mk.
Add Test to PRODUCT_PACKAGES.
PRODUCT_PACKAGES + = Test
5) re-build the entire project
Second. How do I preset the APK without source code into the system? // Cao haoyang's column
1) Under packages/apps, create a folder with the APK name that needs to be preset. The following example uses the preset APK named Test as an example.
2) Put Test.apk under packages/apps/Test
3) Create the Android. mk file under packages/apps/Test. The file content is as follows:
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
# Module name shoshould match apk name to be installed
LOCAL_MODULE: = Test
LOCAL_MODULE_TAGS: = optional
LOCAL_SRC_FILES: = ((local_moduleapps.apk
LOCAL_MODULE_CLASS: = APPS
LOCAL_MODULE_SUFFIX: = $ (COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_PREBUILT_JNI_LIBS: = \
@ Lib/armeabi/libtest. so \
@ Lib/armeabi/libtest2.so
LOCAL_CERTIFICATE: = PRESIGNED
Include $ (BUILD_PREBUILT)
If no so exists, delete LOCAL_PREBUILT_JNI_LIBS.
If so exists, use LOCAL_PREBUILT_JNI_LIBS to list all so paths. Do not forget to use @. @ Identifier: the so in the apk is extracted and built into the lib folder in the same directory of the apk.
If apk supports so of different CPU types, the processing of so is as follows:
Ifeq ($ (TARGET_ARCH), arm)
LOCAL_PREBUILT_JNI_LIBS: = \
@ Lib/armeabi-v7a/xxx. so \
@ Lib/armeabi-v7a/xxxx. so
Else ifeq ($ (TARGET_ARCH), x86)
LOCAL_PREBUILT_JNI_LIBS: = \
@ Lib/x86/xxx. so
Else ifeq ($ (TARGET_ARCH), arm64)
LOCAL_PREBUILT_JNI_LIBS: = \
@ Lib/armeabi-v8a/xxx. so
...
So corresponding to TARGET_ARCH will be extracted soon
4) open the file device \ mediatek \ common \ device. mk.
Add Test to PRODUCT_PACKAGES.
PRODUCT_PACKAGES + = Test
5) re-build the entire project
Note: If the App uses the System-Level permission, you need to reset it under/system/priv-app (originally in/system/app ).
Modify Android. mk and add LOCAL_PRIVILEGED_MODULE: = true to declare that the app must be placed under/system/priv-app.
Third. How do I preset the APK so that users can unmount it and cannot restore it when restoring the factory settings?
1) Under packages/apps, create a folder with the APK name that needs to be preset. The following example uses the preset APK named Test as an example.
2) Put Test.apk under packages/apps/Test
3) Create the Android. mk file under packages/apps/Test. The file content is as follows:
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
# Module name shoshould match apk name to be installed
LOCAL_MODULE: = Test
LOCAL_MODULE_TAGS: = optional
LOCAL_SRC_FILES: = ((local_moduleapps.apk
LOCAL_MODULE_CLASS: = APPS
LOCAL_MODULE_SUFFIX: = $ (COMMON_ANDROID_PACKAGE_SUFFIX)
# LOCAL_PRIVILEGED_MODULE: = true
LOCAL_MODULE_PATH: = $ (TARGET_OUT_DATA_APPS)
LOCAL_CERTIFICATE: = PRESIGNED
Include $ (BUILD_PREBUILT)
4) open the file device \ mediatek \ common \ device. mk.
Add Test to PRODUCT_PACKAGES.
PRODUCT_PACKAGES + = Test
5) re-build the entire project
Note: This is more than undetachable.
LOCAL_MODULE_PATH: = $ (TARGET_OUT_DATA_APPS)
4-Th. How can I preset the APK so that users can uninstall it and restore it when restoring the factory settings?
1. Create a folder with the desired APK name in the context of vendor \ mediatek \ proprietary \ binary \ 3rd-party \ free. The example is to preset an APK named Test.
2. Add test.apk to the vendor \ mediatek \ proprietary \ binary \ 3rd-party \ free \ Test
3. Create the Android. mk file under the vendor \ mediatek \ proprietary \ binary \ 3rd-party \ free \ Test file. The file content is as follows:
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
# Module name shoshould match apk name to be installed
LOCAL_MODULE: = Test
LOCAL_MODULE_TAGS: = optional
LOCAL_SRC_FILES: = ((local_moduleapps.apk
LOCAL_MODULE_CLASS: = APPS
LOCAL_MODULE_SUFFIX: = $ (COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE: = PRESIGNED
LOCAL_MODULE_PATH: = $ (TARGET_OUT)/vendor/operator/app
Include $ (BUILD_PREBUILT)
2 open the file device \ mediatek \ common \ device. mk
Add Test to PRODUCT_PACKAGES.
PRODUCT_PACKAGES + = Test
3. Then build the entire project again.
If you want to run apk as a 32bit apk, You need to define it in Android. mk
LOCAL_MULTILIB: = 32