I'm working on a script via shell for the installation of one or more apk from an USB key plugged in the device. The device is a MID custom, made in China, with root permissions. Android 4.x on-board.

My need is to make sure that the target installation directory (or sub-directory) is in /mnt/sdcard (on which we have much more space than on /data).

I created a file "run.sh" executable (with executable permissions) and I tested various installation methods:

- pm install -s <apkName>.apk
- pm set-install-location 2; pm install <apkName>.apk

In both cases, "pm" allows me to "point" to the sd location.

Until I launch this script directly via shell or invoking external "adb (-s) install" commant etc... Android does his duty and the apk will be installed on /mnt/sdcard.

I shall digress:
(((I noticed that when I point the intallation targeto to /mnt/sdcard using pm and with the -s option, Android creates a virtual filesystem forking with a lot of "/mnt/asec/xxx" ... but I have not found any information about this to try to reproduce this process manually.)))

The problem arises when I have to invoke this script run.sh from an activity.

Calling pm (in any case, with the option -s or not) will fail ... the apk will not be installed and the logcat will back to me this list of messages (which I'm not able to understand)

On the other hand, using the manual method (which is to copy the apk into the directory /data/app and let Android do the work) everything works perfectly, both invoking the script via shell or invoking the script from an activity (through the function above). But, of course, in this case the target destination is "/data" and this is not good for us.

Does anyone have suggestions about that?
Thanks in advance.

Mauro Cecamore