Install / Unistall from shell command in Android

后端 未结 6 1778
一生所求
一生所求 2020-12-28 20:55

I want to implement a silent installer-from-apk-file and unistaller-package in Android. The topic has largely been discussed on SO and elsewhere but I can\'t apply any for s

6条回答
  •  灰色年华
    2020-12-28 21:20

    For all who are still having problem: you will need a rooted device and use

    Process result = Runtime.getRuntime().exec("pm install -r -d MyApp.apk /system/app")
    

    If you are getting result code 9 (error code 9) you will need to delete your apk from the device and push it back (PUSH not INSTAL!).

    Go to the device shell and Push the apk

    launcher=MyApp.apk
    $adb shell su -c "mount -o remount,rw -t rfs /dev/stl5 /system"
    $adb push $launcher /sdcard/$launcher
    $adb shell su -c "chmod 644 /system/app/$launcher"
    

    Now you are able to use pm install without getting an error. Hope it will help somebody.

提交回复
热议问题