Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install APK using Android updater script

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.

like image 806
Ravi Avatar asked Feb 01 '13 19:02

Ravi


1 Answers

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");
like image 52
Paul Lammertsma Avatar answered Oct 01 '22 21:10

Paul Lammertsma