简体   繁体   English

如何使用Android Updater脚本安装APK

[英]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. 我正在尝试使用Android的更新程序脚本语言(Edify?)通过无线方式将APK安装到我可以控制的嵌入式设备上。 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 . 这导致test.apk自动安装在/data/data/com.acme.test ,但是目录/data/data/com.acme.test/lib为空,而目录应该包含test.so ,这是一个共享库包含在test.apk (If I manually install using adb install test.apk , the library is extracted.) (如果我使用adb install test.apk手动安装,则会提取库。)

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: 然后,我尝试将APK提取到/data而不是/data/app以便操作系统不会将其自动安装到/data/data ,我可以尝试使用脚本进行安装:

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? 是否可以安装APK并自动提取其共享库? I could install the libraries manually, but I'm hoping to avoid that. 我可以手动安装库,但我希望避免这种情况。

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. 我不熟悉Edify,但是通过查看文档, package_extract_file()只是将APK提取为其存档文件。 Why data ends up inside /data/data is strange; 为什么数据以/data/data data结尾? 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");

Edify scripts run in a recovery mode and depending on your device not all partitions are available by default. Edify脚本在恢复模式下运行,默认情况下,并非所有分区都可以使用,具体取决于您的设备。 Most likely your problem is that the partition you are trying to use is not mounted yet. 您的问题很可能是您要使用的分区尚未挂载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM