8

I'm attempting to use Android's updater script language (Edify?) to install an APK over-the-air to an embedded device that I have control over. Here's a link that describes the language.

My first attempt was the following:

package_extract_file("added_files/data/app/test.apk", "/data/app/test.apk");

That resulted in test.apk being automatically installed in /data/data/com.acme.test, however the directory /data/data/com.acme.test/lib is empty, whereas it should contain test.so, a shared library contained in test.apk. (If I manually install using adb install test.apk, the library is extracted.)

I then tried extracting the APK into /data instead of /data/app so the OS wouldn't automatically install it into /data/data, and I could try installing using the script:

package_extract_file("added_files/data/app/test.apk", "/data/test.apk");
run_program("/system/bin/pm", "install", "/data/test.apk");

That resulted in the following error:

about to run program [/system/bin/pm] with 3 args
run_program: execv failed: Exec format error
run_program: child exited with status 1

I'm not sure why the above error happened.

Is there a way to install an APK and have its shared libraries extracted automatically? I could install the libraries manually, but I'm hoping to avoid that.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
Ravi
  • 3,718
  • 7
  • 39
  • 57

2 Answers2

1

I'm not familiar with Edify, but by looking at the documentation, package_extract_file() simply extracts the APK as the archive file that it is. Why data ends up inside /data/data is strange; are you sure that isn't just left behind from a previous installation? I'd suggest fully uninstalling the app and trying again.

It seems to me that that particular function isn't suited for installing the app. You might want to try installing it through a command:

run_program("adb", "install", "-r", "added_files/data/app/test.apk");
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • I had clean /data/data, and somehow it was populated after I extracted into /data/app and rebooted. As far as using adb, that's not available on the device itself, it works over USB or TCP/IP, and runs on a separate host like Linux or Windows. If there's an Android native version of adb, let me know. – Ravi Feb 01 '13 at 23:03
  • Incidentally, I believe that adb runs on the device itself, as the relationship is client/server. But if the device's debug setting is disabled, the daemon won't be running. – Paul Lammertsma Feb 01 '13 at 23:06
  • I tried adding "-r" to the pm install example in my question, but that didn't work either. – Ravi Feb 01 '13 at 23:14
  • It would seem that the application executing the script commands doesn't have the [required permissions for installing packages](http://developer.android.com/reference/android/Manifest.permission.html#INSTALL_PACKAGES). I'm not certain about that, though; do you have some way of capturing the stderr of that command? – Paul Lammertsma Feb 01 '13 at 23:20
  • Heh, the documentation states "Returns a string, I assume it is the buffer of the stdout of the program executed, need to test." I guess that doesn't really help us! – Paul Lammertsma Feb 01 '13 at 23:22
  • Yes, the error shown above is from stdout. As far as permissions, it should be OK, though I'm not positive. The application that executes the above commands is in Android's recovery image, which seems to have root privileges. I'm able to run other commands like mkdir, which are in the same owner/group as pm. – Ravi Feb 02 '13 at 15:11
0

Edify scripts run in a recovery mode and depending on your device not all partitions are available by default. Most likely your problem is that the partition you are trying to use is not mounted yet.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • I didn't show the full script, but /system is mounted because I'm able to extract binaries to it. For some reason, I'm not able to run pm. You're right about some partitions not available in recovery, these are ones like bootloader and kernel. – Ravi Feb 10 '13 at 19:27