Method of presetting APK in Android system source code

  • 2021-10-27 08:51:16
  • OfStack

How to preset passive google play APK into the system (there is one difference between active code and passive code, and there is no source code after decompression of google play. apk downloaded online)?

(Note that Test below is the name of googleplay. apk that we want to preset into the source code! ! Google Play Store 4.6. 17. apk downloaded from the Internet, the name contains spaces, remove the spaces or rename it directly)

1. Create a folder under packages/apps with the name of APK that needs to be preset, and prefabricate an APK named Test as an example

2. Place Test. apk under packages/apps/Test

3. Create the file Android. mk under packages/apps/Test as follows:


LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Module name should match apk name to be installed
LOCAL_MODULE := Test
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT) 

4. Open the file build/target/product/${Project}. mk (where ${Project} represents the project name)

Add Test to PRODUCT_PACKAGES.


PRODUCT_PACKAGES := \
  DeskClock \
  Calculator \
  Calendar \
  Camera2 \
  Email \
 Test

Note: Step 5 is not required to preset google play! (No so Library)

5. Copy the so library extracted from Test. apk to the directory of alps/vendor/mediatek/${Project}/artifacts/target/product/${Project}/system/lib/. If there is no so library, remove this step;

Step 6 Compile

Compile the preset apk module separately

1. First of all, under the build directory under the Android source code directory, there is a script file envsetup. sh. After executing this script file, you can get some useful tools:

USER-NAME@MACHINE-NAME:~/Android$ . ./build/envsetup.sh

Note that this is an source command, and after execution, there are 1 additional commands available:

2. Specify compilation mode

lunch 20 (Take 20 eng as an example.)

3. Use the mmm command to compile the specified module.

Execute in the source root directory

.....Android # mmm packages/apps/Test

After compiling, you can see the Test. apk file in the out/target/product/generic/system/app directory. The App that comes with the Android system is placed in this directory.

4. After compiling the module, repackage the system. img file.

Execute the following command in the android source root directory:

USER-NAME@MACHINE-NAME:~/Android$ make snod

When it is finished, it can be burned on the board! ! ! !

Summarize


Related articles: