To install any android application as a system app, ( which can’t be uninstalled from settings ), first important this is, the device on which we need to install apk has to be a rooted device with all the necessary permissions. The user devices which we purchase from off-the shelves market are mostly “user” devices which has restricted permission, hence in such devices there will be no way to install an application as system app, unless you root the device somehow.
But most of the development platforms are allready rooted, hence following commands will work on such,
Connect you device using usb cable and type below commands,
$ adb shell push myname.apk /sdcard
$ adb shell
$ mount -o remount,rw /system
$ mv /sdcard/myname.apk /system/appIf you want you app, to be have little more permissions related to system. ( Something like if your app needs to have almost all permissions and is important to the system ), in that case, use below command,$ mv /sdcard/myname.apk /system/priv-app$ chmod 644 /system/app/myname.apk$ chown -R root /system/app/myname.apk$ chgrp -R root /system/app/myname.apk$ mount -o remount,ro /system$ reboot
This app cant be uninstalled from settings.
Now, if you want to uninstall system app or priv-app, we just need to follow below steps as,$ adb shell$ mount -o remount,rw /system$ rm -rf /system/app/myname.apk$ mount -o remount,ro /system$ reboot
Once the device is rebooted, you will see that app has been removed from system.
- In Depth: Android Package Manager and Package Installer
- mechanism of Android package installation process
Original Link - http://dsas.blog.klab.org/archives/52069323.html
Translated Version Link - Click here
- A sample of how to install applications in the background (without user interaction) on Android
- Install apps silently, with granted INSTALL_PACKAGES permission
- install / uninstall APKs programmatically (PackageManager vs Intents)
- Install / Unistall from shell command in Android
- How to install an application in background on Android
- Auto Update Apk : http://www.auto-update-apk.com/
- packageinstaller - https://android.googlesource.com/platform/packages/apps/PackageInstaller/+/47fe118e0178e9d72c98073ff588ee5cf353258e/src/com/android/packageinstaller
- Installd Daemon : https://android.googlesource.com/platform/frameworks/base/+/0b285499db739ba50f2f839d633e763c70e67f96/cmds/installd/