Search code examples
androidshellandroid-sourceandroid.mk

Android.mk - How to generate resource file on the fly


While build my APK in the AOSP environment, I want to create a temporary resource file which can be generated like this:

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><resources><string name=\"my_tmp_string\" translatable=\"false\">$SOME_ENV_VAR</string></resources>" > res/values/tmp.xml

However, put this in the Android.mk does not work. Does anyone know how to do this?


Solution

  • Try storing the command in a separate shell file like "generate_res.sh" for example, and afterward add a call to your Android.mk file like this:

    $(info $(shell ($(LOCAL_PATH)/PATH_TO_FILE/generate_res.sh)))