Easy way to add custom packages to a LineageOS4MicroG ROM

Posted by

So you have figured out how to build your own custom ROM using Docker…if not click here.
Once you have become an expert at it you would want to add a custom touch to the build. I realized that I was downloading a few apps which I wanted to use. For example – twitter, whatsapp, nextcloud and so on. Now remember these are apps which are not going to be installed by default as they are owned by different organizations and due to licensing issues they cannot and will not be a part of any Lineage ROM that you will download officially from the web. So what do you do?

Simple you add the apk’s to your custom build. Remember as long as you are not going to going to distribute it online you should be ok because as mentioned these applications are licensed to different organizations and not open source.

Steps to add a custom apk to your ROM.

Please note : This method works on the docker setup environment.

Step 1:

Download the apk (s) of your choice. For e.g. say I downloaded nextcloud , Nextcloud notes and twitter apks.

Step 2:

Create a folder with the apk name for e.g. NextCloud or Notes. Something short and simple.

Step 3:

Copy paste the downloaded apk into the folder. Remember to download the correct apk to the designated folder 🙂

Step 4:
Change the name of the apk file. For e.g. the name of the NextCloud apk is com.nextcloud.client_3.3.0-30030099_minAPI14(arm64-v8a,armeabi,armeabi-v7a,x86,x86_64)(nodpi)_apkmirror.com.apk!!!! (download it yourself if you think I am joking)
Rename the apk to something simple for e.g. NextCloud.apk
Do not worry renaming will not impact your build.
Step 5:

Add an Android.mk file with text like below to each of the folders. The below is the sample I always use.
Two values need to be changed in this file.
One the LOCAL_MODULE and the other the LOCAL_SRC_FILES.
For e.g from the below example the words FDroid and Fdroid.apk need to be replaced by the apk folder name and the apk name. If I am adding the NextCloud apk then the value for LOCAL_MODULE will be the folder name i.e. NextCloud and the value for LOCAL_SRC_FILES would be NextCloud.apk.

Similarly you have to create Android.mk files for each of the apks that you are adding.

Each folder will have one apk file and one Android.mk file with the below contents

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := FDroid
LOCAL_SRC_FILES := FDroid.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

Step 6:

Now make a few additions to the following file

vendor/lineage/config/common.mk

Browse down to the PRODUCT_PACKAGES +=

The default line may look like this – (your file would be different from this these are just samples)

PRODUCT_PACKAGES += FDroid GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension

Add the names of the custom packages you have added to make it look something like this

PRODUCT_PACKAGES += FDroid Flym GmsCore GsfProxy FakeStore MozillaNlpBackend NextCloud NominatimNlpBackend Notes com.google.android.maps.jar FDroid FDroidPrivilegedExtension Telegram Twitter WhatsApp WordPress

save the common.mk

Copy the complete list of packages as you would need it in the next step

Step 7: Pass the package list copied from the previous step and pass it to your docker run command for example now your command should look like …with all the custom packages being passed.

docker run \
-e “BRANCH_NAME=lineage-15.1” \
-e “DEVICE_LIST=tissot” \
-e “SIGN_BUILDS=true” \
-e “CCACHE_SIZE=100G” \
-e “SIGNATURE_SPOOFING=restricted” \
-e “CUSTOM_PACKAGES=FDroid Flym GmsCore GsfProxy FakeStore MozillaNlpBackend NextCloud NominatimNlpBackend Notes com.google.android.maps.jar FDroid FDroidPrivilegedExtension Telegram Twitter WhatsApp WordPress ” \
-v “/home/username/lineageos4microg/lineage:/srv/src” \
-v “/home/username/lineageos4microg/zips:/srv/zips” \
-v “/home/username/lineageos4microg/logs:/srv/logs” \
-v “/home/username/lineageos4microg/cache:/srv/ccache” \
-v “/home/username/lineageos4microg/keys:/srv/keys” \
-v “/home/username/lineageos4microg/manifests:/srv/local_manifests” \
lineageos4microg/docker-lineage-cicd:latest

Step 8: Once the build is complete. Pick it up from the zips folder and flash on your phone.

Check all the apps you installed are running

Step 9: Congratulate yourself for having built your customized ROM!!!
Enjoy!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s