Background
In the past, I've asked about sharing or backup of app-bundle / split apk files, here .
This seems like an almost impossible task, which I could only figure out how to install the split APK files, and even then it's only via adb:
adb install-multiple apk1 apk2 ...
The problem
I was told that it should be actually possible to merge multiple split APK files into one that I could install (here), but wasn't given of how to do it.
This could be useful for saving it for later (backup), and because currently there is no way to install split-apk files within the device.
In fact, this is such a major issue, that I don't know of any backup app that can handle split APK files (app bundle), and this include Titanium app.
What I've found
I took a sample app that uses app-bundles, called "AirBnb".
Looking at the files it has, those are what the Play Store decided to download:
So I tried to enter each. The "base" is the main one, so I skipped it to look at the others.
To me it seems that all have these files within:
- "META-INF"
- "resources.arsc"
- "AndroidManifest.xml"
- in the case of the one with the "xxxhdpi", I also get "res" folder.
Thing is, since those all exist in multiple places, I don't get how could I merge them.
The questions
-
What is the way to merge those all into one APK file?
-
Is it possible to install split APK files without root and without PC ? This was possible in the past on backup apps such as Titanium, but only on normal APK files, and not app bundle (split apk).
EDIT: I've set a bounty. Please, if you know of a solution, show it. Show something that you've tested to work. Either of merging split APK files, or installing them , all without root and right on the device.
EDIT: Sadly all solutions here didn't work, with or without root, and that's even though I've found an app that succeeded doing it (with and without root), called "SAI (Split APKs Installer)" (I think its repository is here, found after I've put a bounty).
I'm putting a new bounty. Please, whoever publishes a new answer, show that it works with and without root. Show on Github if needed (and here just the important stuff). I know this app is open sourced anyway, but it's important for me how to do it here, and share with others, as currently what's shown here isn't working, and requires root, even though it's not really needed.
This time I won't grant the bounty till I see something that indeed works (previously I was short on time and granted it to the answer I thought should work).
Best Answer
Please check this. when we send
it calls this code install-multiple
which in turn calls Pm.java or a new way of executing PackageManagerService code, both are similar
I tried to integrate that code in my app, The problem which I faced, apk installation was not able to complete, it is due to the reason that the app needs.
But it is only given to system-priv apps. When I executed these steps from adb shell apk installation was successful and when I created my app a system priv-app apk install was successfull.
code to call new apis of PackageManager, mostly copied from Pm.java Steps in installing split apks
Create a session with argument -S , return session id.
(install-create, -S, 52488426) 52488426 -- total size of apks.
Write split apks in that session with size , name and path
(install-write, -S, 44334187, 824704264, 1_base.apk, -)
(install-write, -S, 1262034, 824704264, 2_split_config.en.apk, -)
(install-write, -S, 266117, 824704264, 3_split_config.hdpi.apk, -)
(install-write, -S, 6626088, 824704264, 4_split_config.x86.apk, -)
commit the session with session id
(install-commit, 824704264)
I have placed airbnb apk in my sdcard.
and calling functions to install apk.
This is the list of commands that are actually received in Pm.java when we do adb install-multiple
So for apps which are not system priv-app, I don't know how can they can install split apks. Play store being a system priv-app can use these apis and install split apks without any issues.