How to Install and Uninstall android application as system app / priv-app

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.


Source Reference:

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply