kolbasa/cordova-plugin-apkupdater

XAPK install support?

Closed this issue · 8 comments

Hi, I would like to ask if there are plans to support installing xapk files? Thank you for this awesome plugin.

Thanks for the suggestion. I will check if this is possible. So far I have no experience with XAPK.

Hi, thank you for the response. I did check the contents of an xapk file, it seems to be a zip file with xapk extension.

This is the directory structure of contents inside the sample xapk file for com.tencent.ig:

Android/obb/com.tencent.ig/main.15527.com.tencent.ig.obb
com.tencent.ig.apk
icon.png
manifest.json

It's like following the same concept of your https://github.com/kolbasa/apk-update but with a different structure and extension, renaming the .xapk file extension to .zip makes it compatible for decompression using zip tools.
I think google play is using this to install apps with large OBB/Data files.

You can also download the sample zip file here, I removed the contents of .apk and .obb files so the sample zip will be smaller: https://dropmb.com/UBrP4

I already tried implementing this feature by modifying your plugin but the code became really messed up since I don't have professional experience with java.

I've taken a look at it now. Here are two examples I looked at:

https://gist.github.com/kolbasa/f1ca877247d655a3b3eab55e62280891
https://gist.github.com/kolbasa/ae4bfab90f099a9890472f0f9a593eb1

I can manage that. There is only one more step: copy the OBB data to the appropriate place.

The only thing that irritates me a bit. I can't find any official documentation about the format of the manifest.json.
For example, there is the property xapk_version. Are there other versions? And where are they documented?

You're right, I also didn't find any official documentation.

XAPK seems to be private for google play use only but I did find a site that explains what is xapk_version: https://openxapkfile.net/manifest.html

In that site, the example manifest format is using 1 and it's different from the xapk_version: 2 that we have in our examples, it seems that it is used to identify the format of the manifest file and based on latest xapk file I downloaded from google play, the latest version of xapk manifest format is 2.

Brief Update. I have now tested the feasibility with a simple prototype.
Looks good. I can already install simple XAPK apps including the OBB data. For the app-data, the permission for external storage is requested during the installation.

It will take me some more time to clean up the code. I'll keep you updated.

Great! If you need more information, just ask me, I'll do the research.

Unfortunately, it always takes quite a bit of time to get a feature ready. It's just a small open source project.

On this branch you can see the progress:

cordova plugin add https://github.com/kolbasa/cordova-plugin-apkupdater#xapk-support

To install OBB data, you now also need the write permission for external storage.
It looks like this:

await ApkUpdater.openInstallSetting(); // true,false (the plugin is now waiting for confirmation here)
await ApkUpdater.requestExternalStorageAuthorization(); // true,false

After both permissions have been granted, the app will restart itself.

Now you can install .xapk files:

For my tests I use this game, but should also work with much larger installation files.

await ApkUpdater.download(
    'http://10.0.2.2:3101/update/update.xapk',
    {
        onDownloadProgress: function(e) {
            console.log("Downloading: " + e.progress + "%");
        }
    }
);

await ApkUpdater.install(
    {
        onUnzipProgress: function(e) {
            console.log("Extracting: " + e.progress + "%");
        }
    }
);

Download

Now I have to test it properly and include the changes in the documentation. This will take some time again :)

XAPK support is now in the 3.0.0 plugin version.