3
votes

I am developing a ROM based on AOSP 5.1.0 source code. I want to add a folder "abc" (it contains some files) to the source code and compile the folder into the "/data/abc" path in the device (Nexus 5).

By now, I use this way to realize it:

1) Add "abc" folder to the root of AOSP source folder.

2) Add an application in /packages/apps/TestApp, in TestApp's Android.mk file, add "$(shell cp -rf $(LOCAL_PATH)/../../../abc/ $(TARGET_OUT_DATA)/abc/)" behind the “include $(CLEAR_VARS)”. $(TARGET_OUT_DATA) seems to mean the "/data/" path in device.

3) make -j12

4) fastboot -w flashall

The above way indeed did the job, but in "out\target\product\hammerhead\data\abc", there is also a "abc" folder in "abc", this is so werid and I don't know what happened. And after I flash the images by "fastboot -w flashall", The "/data/abc" folder lacks many files in Nexus 5.

I don't know if execute "shell cp" in an app's Android.mk is the right way to add a folder to userdata.img, and if not, what's the correct way?

2
Are you trying to install a prebuilt APK, or what kind of files are we talking about? (It's not surprising that you end up with a abc/abc directory structure; your copy command explicitly copies an abc directory into another abc directory.) - Magnus Bäck
There are just some data files (config files used by my apk) in abc directory. If this is an apk, it will be much simpler. Also I misunderstood the grammar, the "abc" in dest folder should be removed. - hsluoyz

2 Answers

2
votes

Finally I got the right way:

fastboot -w flashall will not flash the userdata.img image

You have to flash userdata.img explicitly by executing fastboot flash userdata.

1
votes

You can use $(BUILD_PREBUILT) to copy multiple files. Your Android.mk should look like the following :

include $(CLEAR_VARS)
LOCAL_IS_HOST_MODULE =
LOCAL_MODULE = abc
LOCAL_MODULE_CLASS = ETC
LOCAL_MODULE_PATH = $(PRODUCT_OUT)/data
LOCAL_MODULE_RELATIVE_PATH =
LOCAL_MODULE_SUFFIX =
LOCAL_MODULE_STEM =
LOCAL_MODULE_STEM_32 =
LOCAL_MODULE_STEM_64 =
LOCAL_SRC_FILES = abc/file1 abc/file2
include $(BUILD_PREBUILT)

Also, you need to add that module to your device.mk file :

PRODUCT_PACKAGES += abc

Note: There is probably a better way to copy multiple files (a directory).