Android系统APP通过adb安装更新的方法

Android系统APP通过adb安装更新的方法

    • 普通APP
    • 系统APP(尤其包含so的APP)

普通APP

一般APP可通过adb命令安装:


adb install ***.apk

系统APP(尤其包含so的APP)

  1. 对于包含so的APP,如果通过“adb install”方式安装,System.loadLibrary时,可能会报错:

java.lang.UnsatisfiedLinkError: dlopen failed: library "libbinder.so" not found: needed by **/lib/arm64-v8a/lib***.so in namespace classloader-namespace

  1. 系统APP需要安装在系统分区(例如/system/app或/system/priv-app)。想要吧apk文件推送到系统分区需要Root权限,一般情况下,普通用户无法直接写入系统分区。

  2. 可尝试如下安装方法:

//获取root权限
adb root

//重新挂载文件系统
adb remount

//推送apk到系统路径下
adb push path/updated_app.apk /system/app(or priv-app)/

//重启后生效
adb reboot 
  1. 需要注意的是,最好事先确认你的手机系统中 /system/app 或 /system/priv-app 的目录结构,因为app或priv-app目录下可能存在子文件夹。此时,你需要推送到对应的文件夹下。
blc@blc-HP-Pro-Tower-288-G9-PCI-Desktop-PC:~$ adb root
restarting adbd as root

blc@blc-HP-Pro-Tower-288-G9-PCI-Desktop-PC:~$ adb remount
Using overlayfs for /system
Using overlayfs for /vendor
Using overlayfs for /odm
Using overlayfs for /system_ext
Using overlayfs for /vendor_dlkm
Using overlayfs for /odm_dlkm
Using overlayfs for /product
Now reboot your device for settings to take effect
remount succeeded

blc@blc-HP-Pro-Tower-288-G9-PCI-Desktop-PC:~$ adb shell
rk3588s_wl:/ # cd system
rk3588s_wl:/system # ls
apex  build.prop  framework  priv-app     system_ext  wallpaper
app   etc         lib        product      usr         xbin
bin   fonts       lib64      screensaver  vendor

rk3588s_wl:/system # cd app  
rk3588s_wl:/system/app # ls
Assistant               KeyChain                    SoundRecorder
Bluetooth               NextOSService               chromium
BluetoothMidiService    NextOsOnlineMusic           dangbeishichang
BubbleLauncher-res      NextPrintSpooler            huaweiappmarket
Camera2                 PAMP-VcDemo                 istart


rk3588s_wl:/system/app # cd ../priv-app
rk3588s_wl:/system/priv-app # ls
BackupRestoreConfirmation         MediaCenter
BuiltInPrintService               MediaProviderLegacy
CalendarProvider                  MtpService
CtsShimPrivPrebuilt               MusicFX
DLNA                              PackageInstaller

rk3588s_wl:/system/priv-app # cd MediaCenter/                                  
rk3588s_wl:/system/priv-app/MediaCenter # ls
MediaCenter.apk  oat
rk3588s_wl:/system/priv-app/MediaCenter # 
     

你可能感兴趣的:(android,adb)