Is there a way to change a .bp file of an app in AOSP so that is only included in a certain build.
For example I want to include test apps only in userdebug apps?
The right way to do it is not changing the Android.bp file, but change the device//.mk file to include the tests apps only in userdebug builds like this:
PRODUCT_PACKAGES += main_app_1
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
PRODUCT_PACKAGES += test_main_app_1
endif
In Android.bp, you should build the main app and the test app separately, like this:
cc_binary {
name: "main_app_1",
cflags: [
"-std=c++17",
"-ffunction-sections",
"-fPIC",
"-Werror",
"-Wall",
"-Wextra",
"-O2",
],
srcs: [
"src/**/*.cc",
],
shared_libs: [
"liblog",
"libcutils",
"libandroid_runtime",
"libutils",
],
}
cc_binary {
name: "test_main_app_1",
cflags: [
"-std=c++17",
"-ffunction-sections",
"-fPIC",
"-Werror",
"-Wall",
"-Wextra",
"-O2",
],
srcs: [
"test/**/*.cc",
],
local_include_dirs: ["test/"],
shared_libs: [
"liblog",
"libcutils",
"libandroid_runtime",
"libutils",
],
}