Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

android - How do I add APKs in an AOSP build?

I need to add some 3rd party APKs to my AOSP build. What folder should I keep these APKs so that when I build the code and the image is created, it is installed in the emulator?

It looks like the system apps are kept in the packages/app folder so I need to know where the third party APKs are kept.

question from:https://stackoverflow.com/questions/10579827/how-do-i-add-apks-in-an-aosp-build

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Adding third party APKs to the build is definitely possible.

Also APKs and APPs with source code go to the same place; the package/app folder.

Adding a new APK to the build

In the AOSP root add the folder:

<aosp root>/package/app/< yourappfolder >

Then inside this folder add:

  • empty Android.mk
  • < yourapp.apk >

The android make file should have the reference to your apk, add this to your Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := < your app folder name >

LOCAL_CERTIFICATE := < desired key >

LOCAL_SRC_FILES := < app apk filename >

LOCAL_MODULE_CLASS := APPS

LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

include $(BUILD_PREBUILT)

Create an entry in the commons.mk (from AOSP 8.1.0 onwards it is called core.mk, and is usually found in build/target/product) for your apk add the line (check where all the others are)

PRODUCT_PACKAGES += < what you have defined in LOCAL_MODULE, it should be your app folder name >

Compile the AOSP and you have a brand new app installed on the system.

Notes

  • If your APK is already signed, use the special value PRESIGNED as value for LOCAL_CERTIFICATE
  • If you want your APK to end up in the /data/app/ directory, add the line LOCAL_MODULE_PATH := $(TARGET_OUT_DATA) before the line include $(BUILD_PREBUILT)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...