B10: Exercise: Create your own product
In this exercise you will create your own product and lunch target.
Add product
Create a new device tree directory
mkdir -p device/mycompany cd device/mycompany
In this directory create a AndroidProducts.mk file with the content
PRODUCT_MAKEFILES := \
aosp_my_x86_64:$(LOCAL_DIR)/aosp_my_x86_64.mk
COMMON_LUNCH_CHOICES := \
aosp_my_x86_64-trunk_staging-userdebug
Create a aosp_my_x86_64.mk file with the content
# Base this product on "aosp_cf_x86_64_auto" $(call inherit-product, device/google/cuttlefish/vsoc_x86_64_only/auto/aosp_cf.mk) PRODUCT_MANUFACTURER := MyCompany PRODUCT_NAME := aosp_my_x86_64 PRODUCT_MODEL := My Device Model # This must match a existing BoardConfig.mk within the boards/$(PRODUCT_DEVICE) subfolder. PRODUCT_DEVICE := my_aosp_auto
Create a BoardConfig.mk within the board\my_aosp_auto subfolder, with the content:
-include device/google/cuttlefish/vsoc_x86_64_only/BoardConfig.mk
Now you can already build your new product.
Execute lunch. Your new device should appear.
Select and build it with:
lunch aosp_my_x86_64-trunk_staging-userdebug m -j24
After building it, run the cuttlefish emulator again.
Check that your new product is running with
adb shell getprop | grep model adb shell getprop | grep aosp_my
Check also the Settings application. Under System -> About your Model name should appear.
Add a system property
To add a custom system property to our product, add the following code to your product makefile called aosp_my_x86_64.mk:
PRODUCT_PRODUCT_PROPERTIES += \
ro.mycompany.test=hello
Rebuild, rerun and test with
adb shell getprop ro.mycompany.test
Add a prebuilt application
In the directory device/mycompany/, next to aosp_my_x86_64.mk, file create a file called Android.bp with the content
android_app_import {
name: "MyApp",
presigned: true,
preprocessed: true,
apk: "app-debug.apk",
}
Upload the app-debug.apk into the same directory.
Info
The Soong API reference can be found here.
Be aware that this is for a specific Soong release. If you need the reference for your local AOSP build, checkout the Soong README file that is usually found in the build/soong folder of the AOSP tree.
Add the following code to your product makefile called aosp_my_x86_64.mk:
PRODUCT_PACKAGES += \
MyApp
Rebuild, rerun and test with
adb shell find /system -name MyApp.apk adb shell pm dump de.inovex.aosptraining | less
The SYSTEM flag should be set now and the apk location on the system partition.