I removed a system app (com.android.mms) and I have the .apk needed to restore it, however it won't install through the standard channels (running the .apk gives me "application not installed"). What's the proper way to install a system app's .apk?
4 Answers
You will need to push the .apk to the phone to the System partition to the folder /system/app or /system/priv-app when using Android 4.3 using adb. You can find more info about adb here: http://android-dls.com/wiki/index.php?title=ADB.
In order to write to /system you likely have to remount it read-write:
adb shell su mount -o rw,remount /system Or, do it entirely from the host's ADB:
adb root adb remount Now you can place the .apk:
adb push my-app.apk /sdcard/ adb shell su cd /sdcard mv my-app.apk /system/app # or when using Android 4.3 or higher mv my-app.apk /system/priv-app Afterwards if the flags are not already set change the permissions. All System-Apps need to have the permissions rw-r--r--. You can also change them via ADB with the command chmod 644 /path_to/your_file. Though it's quite old, this may help
After you have placed the .apk you need to reboot your device. For example with adb reboot.
- Yea I figured this would be the way to go, tried it, says bad signature. I used the Mms.apk that is part of the .zip rom I used to install the current android running.Dmitriy Likhten– Dmitriy Likhten2010-09-13 20:34:06 +00:00Commented Sep 13, 2010 at 20:34
- 2Beautiful answer. Thanks. One comment, I was not able to "mv my-app.apk /system/app". I got an error "failed on 'XXX.apk' - Cross-device link". I was able to CP and RM the apk as described in android.stackexchange.com/questions/75920/…Michael Levy– Michael Levy2015-03-03 22:15:35 +00:00Commented Mar 3, 2015 at 22:15
- 2Consider using
cpinstead ofmvbecause you are moving between different file systems and it's not supported in allmvversionsAndres– Andres2015-05-04 00:05:43 +00:00Commented May 4, 2015 at 0:05 - this doesn't update the android permissions with the location of the apk, which is required for packages that use the apkpaIncrease– paIncrease2015-05-16 01:23:28 +00:00Commented May 16, 2015 at 1:23
Carl Parker writes about it on Android Authority:
(partly reproduced here in case the original post goes down)
For Apps Installed on the Device
- Assuming you have installed the app on your device, go to the app’s Google Play Store link and take note of the words after “?id=” and ignore the rest.
- Connect your device to the computer via USB cable.
- Open the command prompt on your computer and type the following commands:
adb remount adb shell su cd /data/app/
- Type the command
ls appfilename*(where “appfilename” is the app’s ID on Google Play Store; make sure you include the asterisk at the end). This command will display the app’s complete APK filename.- Enter the following command:
mv apk_full_filename_here /system/app/apk_full_filename_here exit exit adb reboot
- The device will now reboot. Your app is now saved as a system app.
For Apps Whose APKs Are on the PC Hard Drive
- Open a command prompt on your computer and navigate to where the APK file is located.
- Enable USB debugging on your device and connect your device to the computer via USB cable.
- Enter the following commands:
adb remount adb push apk-filename-here /system/app/ adb shell chmod 644 /system/app/apk-filename-here adb reboot Your phone will automatically reboot. Your app will now be saved as a system app.
note that when playing with adb you will install apps via their package file name (meaning, at the command prompt you will type >adb install myFile.apk)
but you will uninstall them via their package name (>adb uninstall com.this.that.otherthing)
You won't be able to install a package until you've uninstalled its predecessor.
It'll help to add adb to your PATH so that you can just go to the directory where the .apk file is and type adb install myFile.apk.
- Thanks! Didn't know about the uninstall mechanics :)Dmitriy Likhten– Dmitriy Likhten2010-09-13 20:34:46 +00:00Commented Sep 13, 2010 at 20:34
- Have not tried with system apps, but for usual apps
/system/bin/pm(Package Manager) utility worked for me. Likepm install -r myFile.apk(-rfor "replace"). This way you don't need to uninstall and to know package name.Alexander Malakhov– Alexander Malakhov2013-07-04 04:29:15 +00:00Commented Jul 4, 2013 at 4:29
You need to have the Android SDK installed (or at least a tool that's called adb). Further you need to allow "Non Market installs" on your device.
After this is done you change to the folder that contains the file with a console. Then connect your phone (via USB) and run adb install appname.apk
- See other answers' comments. Already have non-market installs enabled since I had swype installed :)Dmitriy Likhten– Dmitriy Likhten2010-09-13 20:35:11 +00:00Commented Sep 13, 2010 at 20:35