6

Background

Without root, I know that it's possible to install a single, normal APK using Intent (here).

Given root, I know that it's possible to install it using this .

This will install the app like a normal installation process, as a user-app.

There is also a way to install a split apk app (here), though for some reason I didn't succeed using it.

The problem

I want to know how to convert and/or install an app to be a system-installed-app, and back to be a user-app.

This includes both APK files of apps that aren't yet installed, and of apps that are already installed.

What I've found

I've found some very old ways to convert an existing app (or installing a new one) into a system app (here, for example or here), saying (in short) I should just move the APK file into /system/app/ path.

Thing is, this might have worked in the past, but now it's not. I think the reason for this is that the apps on /system/app/ exist in a different way now: each app has a folder with some files inside of it.

As for converting back to user app, I can't find it. Same goes for installing a split apk app to system app and convert it back to user app.

In fact, there are apps on the Play store (such as this one) that I remember that could convert other apps into system apps just fine (using root) - now can't do anything.

The questions

  1. When did the method of installing/converting an app to system app worked? How come it doesn't work anymore?

  2. What should be done installing/converting an app to system app, and back to user app, on both old and new Android versions?

  3. Is the same thing possible for split-apk apps (example: AirBnb app) , or at least installed ones?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • So I guess we can't put multiple apks in `/system/priv-app` then...that's why I couldn't get it to work... – Aero Wang Feb 13 '20 at 07:37
  • @AeroWang You succeeded putting one? I thought that on Android 10 it changed too much, that you need some really special workaround like a Magisk module to be able to do that. How did you succeed putting one? – android developer Feb 13 '20 at 08:26
  • I did. I was able to put older version of Youtube Vanced (14.*) into `/system/priv-app` and get it to work, but the newer 15.* comes as splitted apks. – Aero Wang Feb 13 '20 at 10:04
  • @AeroWang Can you please show how you did it for a normal APK ? Maybe share on Github? It works even on Android 10 ? I've tried this for a long time and failed... – android developer Feb 13 '20 at 12:27
  • Really, all I did was to put the apk under `/system/priv-app`, were you not able to put the apk there? I did: `su; mount -o rw,remount /; cd /system/priv-app; mkdir YouTube; cp /scard/Download/YouTube.apk /system/priv-app/YouTube/; cd /system/priv-app/YouTube/; chmod 644 *; reboot` one line of code. – Aero Wang Feb 13 '20 at 14:20
  • @AeroWang And this works on all Android versions? Or just for 10 ? What did you use for before 10 ? On which versions did you check it? – android developer Feb 13 '20 at 15:39
  • It works on all versions from 5 - 10, but it probably doesn't work for all apps - the apps itself must accept root mode - AirBnB for example doesn't support being a root app at all - it will only crash or not appear at all if you put it there. BTW, did you have magisk root? – Aero Wang Feb 14 '20 at 03:52
  • @AeroWang What do you mean "must accept root mode" ? I think AirBnb uses split-apks (AKA app bundle), so that's why you failed it. I've looked at your code. This is for an app that doesn't exist yet. How do you convert an existing app to be system app and back? Also, I tried this via app, and it doesn't seem to work. I don't see it even creating the folder. Are you sure it worked for you? Can you please share a sample project? – android developer Feb 15 '20 at 12:48
  • It works via adb, not via an android app project. U need to connect ur phone to a Mac and open up the terminal and type commands there. I don't think we r on the same page here. Google YouTube vanced. And use adb command above for its 14.* versions. – Aero Wang Feb 16 '20 at 04:09
  • If it doesn't create the folder it means u do not have root priv u will need to install a root priv enabled ROM if there is one for ur phone or try to use magisk and see if it works w ur current ROM. If not u will have to change ur phone. U can use pixels or oneplus phones. – Aero Wang Feb 16 '20 at 04:12
  • @AeroWang I have a rooted Pixel 4 device (using Magisk) on a stock ROM. Isn't it enough? – android developer Feb 16 '20 at 06:18
  • It is. Did you google and download "Youtube Vanced" and connect ur phone to ur mac while running the commands? You should download Youtube Vanced to `/scard/Download/YouTube.apk`. And if you have trouble creating a directory with `mkdir YouTube` then u must have done something wrong with your root. I can't help you without the actual phone in front of me. – Aero Wang Feb 16 '20 at 11:53
  • Did you try to run `su; mount -o rw,remount /; cd /system/priv-app; mkdir YouTube; cp /scard/Download/YouTube.apk /system/priv-app/YouTube/; cd /system/priv-app/YouTube/; chmod 644 *; reboot` via `adb shell`? It doesn't work in an app. – Aero Wang Feb 16 '20 at 11:56
  • Yes, I tried inside an app. That's why I wrote to share it on Github. I thought you succeeded doing it in code... You say that it's impossible inside an app? – android developer Feb 16 '20 at 13:44
  • Yes obviously you will not be able to run `mount -o rw,remount /` in an app. – Aero Wang Feb 17 '20 at 02:06
  • @AeroWang Not obvious. Seems it was possible so far, except on Android 10. You can notice various apps that offer to convert to system apps working on all Android versions except for Android 10. The only solution I've found so far to convert to system app is this one: https://github.com/stangri/AppSystemizer https://forum.xda-developers.com/showthread.php?t=3477512 . Sadly it doesn't currently have the option to convert back to a system app. Also not sure about ability to convert app-bundle based apps. – android developer Feb 17 '20 at 08:29
  • It's "obvious" because it's a magisk change stated on its home page. You can still use other root method and use `mount -o rw,remount /` provided if the root method allows it. – Aero Wang Feb 17 '20 at 10:06
  • It's not specific to Android 10, new magisk builds will not mount root even in Android 9 or 8. It's just that in Android 10 you may only install these new magisk builds. – Aero Wang Feb 17 '20 at 10:07
  • @AeroWang I remember I could use these apps on Android 8 and 9. You say that if I try today using the new Magisk versions, it won't let me? What do you mean by "You can still use other root method and use mount -o rw,remount / provided if the root method allows it. " ? This is a way to still be able to convert ? Please explain. To me it looks exactly as the code you wrote about, which I already said it doesn't work. – android developer Feb 17 '20 at 15:08
  • "If I try today using the new Magisk versions, it won't let me" - Yes. I don't about "other root method," meaning u will need to discover a root solution by urself - instead of using magisk. – Aero Wang Feb 18 '20 at 02:28

3 Answers3

0

Below described process won't work with every android build versions but in most cases it will work as expected.

1 - When did the method of installing/converting an app to system app worked? How come it doesn't work anymore?

You have two situations to install the application like system app.

  1. When building an android image You can place the application you want system privileges in /system/app folder and building system will sign it with the platform key and it will work as a system application.

  2. After gaining root permission of installed images If you can access your android system as the root user, then you can simply push the certain application to /system/app directory on android device.

2 - What should be done installing/converting an app to system app, and back to user app, on both old and new Android versions?

If you want to make your application as a system application, you need to add android:sharedUserId="android.uid.system" as application attribute on your AndroiManifest.xml file

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:sharedUserId="android.uid.system"
        android:theme="@style/AppTheme">

For most of the custom images, manufacturer toolkit is provided and it can be used to create a new image file with system applications. If you don't have such a tool, you can root your device and push apk file to system/app directory. According to my understanding, we don't have any straight forward way to revert back system app to user app. What you can do is simply uninstall system application and again install it as user application.

3 - Is the same thing possible for split-apk apps (example: AirBnb app), or at least installed ones?

Above procedure should work with split-apk apps. But unable to confirm because I have no prior experience.

WMG
  • 326
  • 3
  • 9
  • You didn't answer the question. I want to know how to install APK files and convert existing apps as system apps, and to be able to revert them back to be user-apps. You didn't explain any of those types. – android developer Jun 02 '19 at 10:02
  • Most of the custom Android images, producer release a toolkit to alter and rebuild the image. If you got such toolkit, follow what I have mentioned in Answer 2 and upload newly build apk to given tools and it will produce a custom image with your application as a system app. Then you can install the custom image on your Android device. If you don't have any toolkit provided by image manufacturer, generally you can sign your app with platform keys and push your application to /system/app. If you want to convert it back to a user-app, just uninstall system app and install it as user app. – WMG Jun 02 '19 at 10:56
  • Again, you are not talking about what I asked about. I asked, given root, how to install an APK or convert an existing app to be a system app, and back to be a user app. I didn't ask about building a custom rom and putting there what I want. There are apps that convert existing apps already. I even mentioned an app that could do it before, and now it can't : https://play.google.com/store/apps/details?id=de.j4velin.systemappmover&hl=en&rdid=de.j4velin.systemappmover , Please read the whole question. – android developer Jun 02 '19 at 11:01
  • I understand your question. But unfortunately, you won't get any straightforward way to do that. My advice is don't stick to an application, instead move with basics. Good luck. – WMG Jun 02 '19 at 11:17
  • I don't stick to anything. I ask how to do it using root, just as apps could do it. – android developer Jun 02 '19 at 11:18
0

As I know the procedure which define system app has changed over the time. The Privileged Permission Whitelisting AOSP documentation may help you:

Privileged applications are system applications located in the /system/priv-app directory on the system image. Historically, device implementers had little control over which signature|privileged permissions could be granted to privileged apps. Starting in Android 8.0, implementors can explicitly whitelist privileged apps in the system configuration XML files in the /etc/permissions directory. Apps not explicitly listed in these XML files are not granted privileged permissions.

  • You didn't answer the question. I want to know how to install APK files and convert existing apps as system apps, and to be able to revert them back to be user-apps. You didn't explain any of those things. – android developer Jun 02 '19 at 10:02
  • When I had to work on an application which works only as system app then I followed this description. I put the APK to `/system/priv-app` and I also provided the necessary XML file with privileged permission. Unfortunately, I did as ADB root. So, my idea, if you want to do this from Android as root then you would try to do the same by code. – János Sicz-Mesziár Jun 03 '19 at 17:00
  • Did you do it before installing or after? And what were your commands for it? – android developer Jun 04 '19 at 07:35
0

The apk i saw for rooted phones or w.e is called systemizer apk it claims to turn any apk into system apk thrpugh it and prolly back again is what im assuming it could or couldnt but nice if it does =} id decompile it and see what it does to do sucha thing if i needed the code instead for my own project.