Adding pre-built apps to your build

One of the big things that always comes up is that of adding pre-built apps to your build. Make is so dynamic that you could add these in just about anywhere, provided that you properly add them to your configuration files. For myself, I used to add them into the vendor directory, but this became tedious when I would switch to build something else with the same repository, or when I would update or change to other repositories but wanted the same pre-built apps.

I recently realized that there was an easy way around this, and I wanted to share that with others. Most of you probably already know how to do this, but perhaps someone can benifit from this. Besides, if I ever forget, I can just look here for a reference!

I like to add the Kernel Adiutor app to my JFLTETMO (Samsung Galaxy S4, T-Mobile variant) builds. Like I mentioned above, I used to put it in the vendor directory. What I realized though, is that I can simply add it to my jfltetmo repository under the devices. For my device, I have a jfltetmo repository, which essentially sets a few flags and passes the buck to the jf-common repository for building. So, I actually added the app to my jf-common repository. Now, when I sync, it updates my jf-common directory, and keeps my prebuilt app!

Here is what I did.

Added some folders:

In my jf-common repository (dev/samsung/jf-common) I added a directory called “prebuilt”. In keeping with Android’s common structures, I then created these two folders: “common” and in that folder, one called “app”.
When you are done making directories, it should have a path like this:

[CODE]
jf-common/prebuilt/common/app
[/CODE]

Now, in the “app” folder, I placed my prebuilt app, the Kernel Adiutor app, which I named “ka.apk”. I then made an Android.mk file in the “prebuilt” folder that looks like this:

[CODE]
# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH := $(call my-dir)

#
# Prebuilt APKs
#

include $(CLEAR_VARS)
LOCAL_MODULE := ka
LOCAL_MODULE_OWNER := aokp
LOCAL_SRC_FILES := common/app/$(LOCAL_MODULE).apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .apk
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
[/CODE]

You can add as many prebuilt apps as you want this way, just make the above block for each app. Then you simply add them to your jf-common.mk file in the jf-common directory. You can substitute your device name here, it should work the same. Notice that the lines which have more than one app have the “\” denoting that there are more files to add. Pretty simple, right?

[CODE]
# WJH adding kernel adiutor apk
PRODUCT_PACKAGES += \
ka \
camera.msm8960
[/CODE]

Linux – keep it simple.

 

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s