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
$ su
$ mount -o remount,rw /system
$ mv /sdcard/myname.apk /system/app
If 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.
- 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
https://github.com/paulononaka/Android-InstallInBackgroundSample - Install apps silently, with granted INSTALL_PACKAGES permission
http://stackoverflow.com/questions/5803999/install-apps-silently-with-granted-install-packages-permission - install / uninstall APKs programmatically (PackageManager vs Intents)
http://stackoverflow.com/questions/6813322/install-uninstall-apks-programmatically-packagemanager-vs-intents - Install / Unistall from shell command in Android
http://stackoverflow.com/questions/14871570/install-unistall-from-shell-command-in-android - How to install an application in background on Android
https://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/ - Auto Update Apk : http://www.auto-update-apk.com/
Source Reference:
- 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/
1 thought on “How to Install and Uninstall android application as system app / priv-app”