Adding Your Own App

Intro: Adding a new app to the build

So after completing a build, people have been asking how to add their own app(s) to the CyanogenMod .zip file.

The “easy” way– Add it to the zip manually

One way to do this is to simply add the .apk into the .zip and then edit the recovery installation script (written in a simple scripting language called “edify“) to copy the file from the .zip to the device.

The “right” way: Make a part of the build repository so it auto-builds

Add app source to /packages/apps

You can do this manually, or you can do it via the .repo/local_manifests/*.xml. If you do it this way, a repo sync will update the source to your app from whatever git repository you name in the local manifest. It’s pretty easy to use, and allows you to override/replace/add/remove any official CM repository with one or more of your own.

Determine the name of the project from Android.mk

Regardless of how you put the source in packages/apps/, assuming that the source for the app has an Android.mk Makefile, you can get it to automatically build and install the resulting file in your $OUT directory (and thus your .zip) by simply determining the name of the project, which is typically defined in Android.mk with this:

LOCAL_PACKAGE_NAME := MyPackageName

Add the project to device.mk (or whatever .mk) in the device folder

Then just add that project to be built in the /device/[MANUFACTURER]/[CODENAME]/device.mk file.

Example:

Let’s look at the grouper device aka the Nexus 7. You want to find where the list of packages to build is for this device, in device/asus/grouper/device-common.mk.

Note:

For the nexus 7, the device-common.mk file is shared with the tilapia device (the Nexus 7 GSM version), so if you’re building for another device that doesn’t have device-common.mk, you’d probably make the edit to device.mk instead.

Now you have a choice. If PRODUCT_PACKAGES was previously defined, you can add a value like this:

PRODUCT_PACKAGES += MyPackageName

The += part means to append it to the list.

Or, if it’s simpler, you can just add it to the end an existing PRODUCT_PACKAGES list of projects by appending a “\” to the last item and then adding MyPackageName at the end. Notice that you can’t put any commented lines (ie, lines starting with #) or even blank lines in the list of items to be built.

So if the list looks like this…

PRODUCT_PACKAGES := \
lights.grouper \
audio.primary.grouper

…you’d add it to the end:

PRODUCT_PACKAGES := \
lights.grouper \
audio.primary.grouper \
MyPackage

If the source for your app does not have the Android.mk makefile stuff, you’ll need to add it. You can use any of the existing packages in packages/apps as a model for what needs to be done to build your particular app.

See here for official documentation on Android .mk files.

Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.