简体   繁体   English

更新AOSP内置系统应用程序

[英]Update AOSP built-in system app

Lets say we have downloaded, built and flashed AOSP source code. 假设我们已经下载,构建并刷新了AOSP源代码。 Now a change to a system app is made (eg changed a constant in the packages/apps/Nfc package). 现在更改系统应用程序(例如,在packages / apps / Nfc包中更改为常量)。

The next step is to build it, and there are two ways to do it: 下一步是构建它,有两种方法可以做到:

cd packages/apps/Nfc; mm

or 要么

mmm Nfc

This will create out/target/product//system/app/NfcNci/NfcNci.apk file 这将创建/ target / product // system / app / NfcNci / NfcNci.apk文件

Which is the proper way to update the system app? 哪种更新系统应用程序的正确方法?

I tried using adb install NfcNci.apk but no success: 我尝试使用adb install NfcNci.apk但没有成功:

~/android/aosp-7.1.2-3.10-v2/out/target/product/kugo/system/app/NfcNci$ adb install NfcNci.apk
Failed to install NfcNci.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install com.android.nfcnci without first uninstalling.]
~/android/aosp-7.1.2-3.10-v2/out/target/product/kugo/system/app/NfcNci$ adb install -r NfcNci.apk
Failed to install NfcNci.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.android.nfcnci-1: Package /data/app/com.android.nfcnci-1/base.apk code is missing]

Found a way to easily 're-install' the app itself (let's put Settings app as an example): 找到了一种轻松“重新安装”应用程序本身的方法(让我们以设置应用程序为例):

mmm packages/apps/Settings  # Build the module
adb root ; adb remount  # Restart adbd as root and mount /system as writable
adb push out/target/product/<device_name>/system/priv-app/Settings /system/priv-app  # Push the built files to the device

Then force-close and restart the app (by swiping it from Recents ). 然后强制关闭并重新启动应用程序(通过从“ 最近”中滑动)。 No need to reboot device in order to take changes 无需重启设备即可进行更改

NOTE: Depending on the app, the path may be on system/app instead of /system/priv-app 注意:根据应用程序的不同,路径可能位于system/app而不是/system/priv-app

Another way is to: 另一种方式是:

  1. copy the new apk to the sdcard of the device with adb push 使用adb push将新apk复制到设备的SD卡
  2. mount /system read write: mount -o rw,remount,rw /system mount / system read write: mount -o rw,remount,rw /system
  3. copy your new .apk from /sdcard over your old .apk in /system/app 将/ sdcard中的新.apk复制到/ system / app中的旧.apk上
  4. remove the .odex file of your old .apk 删除旧.apk的.odex文件
  5. reboot the device 重启设备

For development you can use a simple script for this steps. 对于开发,您可以使用简单的脚本执行此步骤。

Check build/envsetup.sh file - there's also commands mmp and mmmp to build and push a module to connected device. 检查编译/ envsetup.sh文件-有还命令mmpmmmp建立和推动一个模块连接的设备。 Also adb sync can be used to sync whole image, so if you updated a module, changed files will be pushed to device. 此外, adb sync可用于同步整个图像,因此如果您更新了模块,则更改的文件将被推送到设备。

Also you can put the changed files via regular `adb push' and reboot device. 您也可以通过常规的'adb push'和重启设备来放置更改的文件。

I do not know if system apps can be updated via adb install , probably yes, but I think you need to increment build number in the manifest file. 我不知道是否可以通过adb install更新系统应用程序,可能是的,但我认为您需要在清单文件中增加内部版本号。

I do not think you can uninstall a system app with adb install -r , as apps can't be removed from system partition, only from data . 我不认为您可以使用adb install -r卸载系统应用程序,因为无法从system分区中删除应用程序,只能从data删除。 I do not know why you are getting INSTALL_FAILED_INVALID_APK in that case, may be because app manager can't uninstall the base system apk indeed. 我不知道你为什么在这种情况下得到INSTALL_FAILED_INVALID_APK,可能是因为app manager无法卸载基本系统apk。

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

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