How to preset Android APK

Source: Internet
Author: User

How to preset Android APK
There are four premade APK cases:

1. How to preset the APK with source code into the system?
2. How to preset the APK without source code into the system?
3. How does one preset the APK so that users can uninstall it and cannot restore it when restoring the factory settings?
4. How does one preset the APK so that users can unmount it and restore it when restoring the factory settings?


The method to implement the pre-fabricated APK is as follows;

I. How to preset the APK with source code into the system? 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 := optionalLOCAL_SRC_FILES := $(call all-subdir-java-files)LOCAL_PACKAGE_NAME := Testinclude $(BUILD_PACKAGE) 
4) open the file build/target/product/$ {Project}. mk ($ {Project} indicates the Project name)
Add Test to PRODUCT_PACKAGES.
5) re-build the entire project

2. How can I preset an APK without source code into the system? 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 should match apk name to be installedLOCAL_MODULE := TestLOCAL_MODULE_TAGS := optionalLOCAL_SRC_FILES := $(LOCAL_MODULE).apkLOCAL_MODULE_CLASS := APPSLOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)LOCAL_CERTIFICATE := PRESIGNEDinclude $(BUILD_PREBUILT)

4) open the file build/target/product/$ {Project}. mk ($ {Project} indicates the Project name)
Add Test to PRODUCT_PACKAGES.
5) copy the so library extracted from test.apk to the directory alps/vendor/mediatek/$ {Project}/artifacts/out/target/product/$ {Project}/system/lib, if no so library exists, remove this step;
6) re-build the entire project
Note: Google modifies the permission control mechanism whose protection Level is System on KK.
If the App uses the System-Level permission, you need to reset it under/system/priv-app (originally in/system/app ).
For example:
In this case, the App must declare WRITE_MEDIA_STORAGE permission in AndroidManifest. xml to obtain the sub-card write permission.


(Ref: KK/alps/frameworks/base/cZ tables? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> encrypt/Co7o8YnI + c1_vcd4kpha + pgltzybzcm9" http://www.2cto.com/uploadfile/Collfiles/20140723/2014072309052360.bmp "alt =" \ ">

On KK, you need to use the following method to obtain the permission:
Modify Android. mk and add LOCAL_PRIVILEGED_MODULE: = true to declare that the app must be placed under/system/priv-app.

3. How can I preset an APK so that users can uninstall 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 should match apk name to be installedLOCAL_MODULE := TestLOCAL_MODULE_TAGS := optionalLOCAL_SRC_FILES := $(LOCAL_MODULE).apkLOCAL_MODULE_CLASS := APPSLOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)LOCAL_CERTIFICATE := PRESIGNEDLOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)include $(BUILD_PREBUILT)

4) open the file build/target/product/$ {Project}. mk ($ {Project} indicates the Project name)
Add Test to PRODUCT_PACKAGES.
5) re-build the entire project
Note: This is more than undetachable.
LOCAL_MODULE_PATH: = $ (TARGET_OUT_DATA_APPS)

4. How can I preset an APK so that users can uninstall it and restore it when restoring the factory settings? Method 1: Set the apk to system/vendor/operator as follows:
Under packages/apps, create a folder with the pre-configured APK name. Take the pre-configured APK named Test as an example:
1) Put test.apk under packages/apps/Test;
2) 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 should match apk name to be installedLOCAL_MODULE := TestLOCAL_MODULE_TAGS := optionalLOCAL_SRC_FILES := $(LOCAL_MODULE).apkLOCAL_MODULE_CLASS := APPSLOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)LOCAL_CERTIFICATE := PRESIGNEDLOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/appinclude $(BUILD_PREBUILT) 
3) open the file build/target/product/$ {Project}. mk ($ {Project} indicates the Project name) and add Test to PRODUCT_PACKAGES.
4) re-build the entire project


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.