是否可以将预构建的APK作为用户应用程序添加到AOSP构建中? [英] Is it possible to add a prebuilt APK to an AOSP build as an user app?

查看:63
本文介绍了是否可以将预构建的APK作为用户应用程序添加到AOSP构建中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将预构建的APK添加到我的AOSP构建中.我已经可以通过执行以下操作来做到这一点:

I am looking to add a prebuilt APK to my AOSP build. I can already do this by doing the following:

  1. 将APK添加到 $ root_of_my_source_tree/packages/apps 文件夹中.
  2. 创建一个 Android.mk 文件.该文件具有以下内容:

  1. Add the APK to the $root_of_my_source_tree/packages/apps folder.
  2. Create an Android.mk file. The file has the following contents:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := <name of APK>

LOCAL_SRC_FILES := <Name of APK>.apk

LOCAL_MODULE_CLASS := APPS

LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_CERTIFICATE := platform

include $(BUILD_PREBUILT)

  • 添加:

  • Add:

    PRODUCT_PACKAGES += \ <name of APK>
    

    生成一个由AOSP构建系统提取的make文件.

    To a make file that gets picked up by the AOSP build system.

    这会将APK添加到只读的/system/app 文件夹中,因此用户将无法更新APK.我希望将APK放置在/data/app 文件夹中,以便用户可以实际更新预建的APK.

    This adds the APK to the /system/app folder which is read-only so the user will not be able to update the APK. I would like the APK to be placed in the /data/app folder so the user can actually update the prebuilt APK.

    我尝试了中的建议问题,他们没有工作.我在

    I have tried the suggestions in this question and they did not work. I tried the suggestion in this question and while it did output the APK to the /data/app folder of the finished build, once I flashed the image onto my device, the app was not there. The second answer in that question does provide a possible explanation for this but no other suggestions.

    最终,我需要在我的版本中预加载一个可以更新的APK,因此,如果这不起作用或者是一种不好的方法,我可以接受建议.

    Ultimately, I need an APK preloaded in my build that can be updated so if this doesn't work or is a bad approach, I am open to suggestions.

    推荐答案

    我发现PackageManager类的标准行为足以满足我的用例.因此,这里有一些花絮值得解释:

    I found the standard behavior of the PackageManager class good enough for my use case. So here are a couple tidbits worth explaining:

    • Lavakush的答案确实起作用,并且确实将APK输出到源树中的 out/target/product/vendor/data/app 文件夹中,但APK并未显示在/下闪存中的数据/应用在系统映像中.根据答案,Android构建系统不会在/data/中构建任何内容,因此可以解释那.我仍然感到困惑,但是它确实显示为 out/target/product/vendor/data/app 文件夹中的输出.
    • 在我的用例中,我需要将APK预加载到构建中,然后根据需要对其进行更新.由于/system/app 文件夹的只读性质,我认为我将无法更新我的应用程序,这就是为什么我想将其预加载到/data/app .事实证明,根据答案&在我的测试中, PackageInstaller 类的标准行为是将更新的APK安装到 data/app 文件夹中,并开始运行此APK,而不是预先加载的/系统/应用 APK.答案还说,设置->应用屏幕将为您提供卸载更新的APK的选项,然后您将剩下原始的 system/app APK.我确实观察到了这种行为,这对我的用例来说是很好的.
    • Lavakush's answer does work and it does output the APK to the out/target/product/vendor/data/app folder in the source tree but the APK does not show up under /data/app in the system image once it's flashed onto a device. According to this answer, the Android build system does not build anything into /data/ so that explains that. I still find it confusing that it does show up as output in the out/target/product/vendor/data/app folder however.
    • In my use case, I need to preload APKs onto a build and then update them as needed. Due to the read-only nature of the /system/app folder I assumed that I would not be able to update my app which is why I wanted to preload it to /data/app. As in turns out, according to this answer & to my testing, the PackageInstaller class' standard behavior is to install the updated APK to the data/app folder and to start running this APK instead of the preloaded /system/app APK. The answer also says that the settings->apps screen will give you the option to uninstall the updated APK and then you'll be left with the original system/app APK. I did observe this behavior and it is fine for my use case.

    这篇关于是否可以将预构建的APK作为用户应用程序添加到AOSP构建中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆