Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XAPK Support #682

Open
ArnoldSmith86 opened this issue Jul 16, 2023 · 41 comments
Open

XAPK Support #682

ArnoldSmith86 opened this issue Jul 16, 2023 · 41 comments
Labels
bug Something isn't working high priority This issue is a high priority installer This bug/feature is about how apps are installed

Comments

@ArnoldSmith86
Copy link

Screenshot_20230716-110838_Obtainium.png

Screenshot_20230716-110852_Obtainium.png

What details do you need?

@ImranR98
Copy link
Owner

I'm able to install this with no issue. Could you try installing it manually without Obtainium?

@ImranR98 ImranR98 added the needs follow up Further information is requested label Jul 16, 2023
ImranR98 added a commit that referenced this issue Jul 16, 2023
 Make page transition animation optional (#683), Add reverse transition animation toggle (#683), Fix text alignment + visibility on app page (#680), Attempt at more resilient XAPK installs (#682)
@ImranR98
Copy link
Owner

Actually try it with this new release first: https://github.com/ImranR98/Obtainium/releases/tag/v0.13.18-beta

@ArnoldSmith86
Copy link
Author

With new release: Screenshot_20230717-124911_Obtainium.png

@ArnoldSmith86
Copy link
Author

After uninstalling first: Screenshot_20230717-125110_Obtainium.png

@ArnoldSmith86
Copy link
Author

Installing using https://f-droid.org/en/packages/com.smartpack.packagemanager/ worked fine:

Screenshot_20230717-130210_Package Manager.png

Not sure how else to install XAPKs.

@1xFF
Copy link
Contributor

1xFF commented Jul 24, 2023

I wonder if that config apk is actually being installed by that app

@ArnoldSmith86
Copy link
Author

It lets me select what to install. I have no idea how all that xapk stuff works, though.

@ImranR98 ImranR98 added bug Something isn't working and removed needs follow up Further information is requested labels Aug 5, 2023
@ArnoldSmith86
Copy link
Author

ArnoldSmith86 commented Aug 16, 2023

Not sure if this helps but:

:/data/local/tmp # cp /storage/emulated/0/Android/data/dev.imranr.obtainium/cache/com.agilexrobotics-523288793.xapk-dir/*apk .
:/data/local/tmp # ls -l
total 71180
-rw-r----- 1 root root      34735574 2023-08-16 10:39 com.agilexrobotics.apk
-rw-r----- 1 root root         45465 2023-08-16 10:39 config.ar.apk
-rw-r----- 1 root root      35960961 2023-08-16 10:39 config.arm64_v8a.apk
-rw-r----- 1 root root        192921 2023-08-16 10:39 config.de.apk
-rw-r----- 1 root root        225689 2023-08-16 10:39 config.en.apk
-rw-r----- 1 root root        323993 2023-08-16 10:39 config.es.apk
-rw-r----- 1 root root        201113 2023-08-16 10:39 config.fr.apk
-rw-r----- 1 root root         74137 2023-08-16 10:39 config.hi.apk
-rw-r----- 1 root root         41369 2023-08-16 10:39 config.in.apk
-rw-r----- 1 root root        168345 2023-08-16 10:39 config.it.apk
-rw-r----- 1 root root         78233 2023-08-16 10:39 config.ja.apk
-rw-r----- 1 root root         78233 2023-08-16 10:39 config.ko.apk
-rw-r----- 1 root root         37273 2023-08-16 10:39 config.my.apk
-rw-r----- 1 root root         78233 2023-08-16 10:39 config.pt.apk
-rw-r----- 1 root root         82329 2023-08-16 10:39 config.ru.apk
-rw-r----- 1 root root         33177 2023-08-16 10:39 config.th.apk
-rw-r----- 1 root root         33177 2023-08-16 10:39 config.tr.apk
-rw-r----- 1 root root         37273 2023-08-16 10:39 config.vi.apk
-rw-rw---- 1 root everybody   124926 2023-08-16 10:39 config.xhdpi.apk
-rw-r----- 1 root root        184729 2023-08-16 10:39 config.zh.apk
:/data/local/tmp # pm install *apk
Success

(Without moving to the temp dir, pm install told me that it couldn't access the file. Note that I can install other apps using Obtainium just fine. I'm not sure if maybe all xapk apps fail, though.)

@zen0bit
Copy link
Contributor

zen0bit commented Sep 16, 2023

Screenshot_20230916_224901.jpg

@1xFF
Copy link
Contributor

1xFF commented Sep 17, 2023

@zen0bit That is caused by using a link with the mobile subdomain m.apkpure.com
It should just be apkpure.com
#543

@YOGIAOGI
Copy link

When I'm using the link without subdomain m, I get not found message when I want to add the app

@1xFF
Copy link
Contributor

1xFF commented Sep 23, 2023

What's the full link you're trying to add?

@YOGIAOGI
Copy link

That's the link.

https://apkpure.com/pl/douyin/com.ss.android.ugc.aweme

I found out that, when I tried to add call of duty warzone mobile, it worked, but download process was stuck at 0%

@ImranR98
Copy link
Owner

It's the /pl/ - will fix in the next release (not the main issue though).

@ArnoldSmith86
Copy link
Author

This got a lot better with recent releases BTW. I don't get errors anymore but every now and then an update renders an app useless. It's still installed but apparently missing some of its split apks. It's still installed but usually doesn't get past its splash screen.

Most of the time updates work fine now though.

@ArnoldSmith86
Copy link
Author

ArnoldSmith86 commented Jan 4, 2024

https://apkpure.com/discord-talk-chat-hang-out/com.discord 210.10 broke my app again.

Fixed by manually downloading apk from https://www.apkmirror.com/apk/discord-inc/discord-chat-for-gamers/discord-chat-for-gamers-210-10-stable-release/discord-talk-chat-hang-out-210-10-stable-android-apk-download/ (apkpure.com seems to be down) to /data/local/tmp and using pm install:

:/data/local/tmp # unzip /sdcard/Download/com.discord_210.10_-_Stable-210010_4arch_4dpi_20lang_4dd1f8eb07d9593d231c151823f28841_apk>
Archive:  /sdcard/Download/com.discord_210.10_-_Stable-210010_4arch_4dpi_20lang_4dd1f8eb07d9593d231c151823f28841_apkmirror.com.apkm
  inflating: split_config.en.apk
  [...]
  inflating: split_config.arm64_v8a.apk
:/data/local/tmp # ls -l
total 295916
-rw-r--r-- 1 root root       58 2024-01-05 13:56 APKM_installer.url
drwxr-xr-x 2 root root     4096 2024-01-05 13:56 META-INF
-rw-r--r-- 1 root root 63800600 2024-01-05 13:56 base.apk
-rw-r--r-- 1 root root     7656 2024-01-05 13:54 discord
-rw-r--r-- 1 root root     8976 2024-01-05 13:56 icon.png
-rw-r--r-- 1 root root     1107 2024-01-05 13:56 info.json
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.ar.apk
-rw-r--r-- 1 root root 48818414 2024-01-05 13:56 split_config.arm64_v8a.apk
-rw-r--r-- 1 root root 34359684 2024-01-05 13:56 split_config.armeabi_v7a.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.bn.apk
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.de.apk
-rw-r--r-- 1 root root    49561 2024-01-05 13:56 split_config.en.apk
-rw-r--r-- 1 root root    37273 2024-01-05 13:56 split_config.es.apk
-rw-r--r-- 1 root root    37273 2024-01-05 13:56 split_config.fr.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.gu.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.hi.apk
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.in.apk
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.it.apk
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.ja.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.kn.apk
-rw-r--r-- 1 root root  9052915 2024-01-05 13:56 split_config.mdpi.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.mr.apk
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.ms.apk
-rw-r--r-- 1 root root    29081 2024-01-05 13:56 split_config.nl.apk
-rw-r--r-- 1 root root    37273 2024-01-05 13:56 split_config.pt.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.ru.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.ta.apk
-rw-r--r-- 1 root root    33177 2024-01-05 13:56 split_config.te.apk
-rw-r--r-- 1 root root 51832620 2024-01-05 13:56 split_config.x86.apk
-rw-r--r-- 1 root root 54024205 2024-01-05 13:56 split_config.x86_64.apk
-rw-r--r-- 1 root root 10245096 2024-01-05 13:56 split_config.xhdpi.apk
-rw-r--r-- 1 root root 14907795 2024-01-05 13:56 split_config.xxhdpi.apk
-rw-r--r-- 1 root root 15034840 2024-01-05 13:56 split_config.xxxhdpi.apk
-rw-r--r-- 1 root root    45465 2024-01-05 13:56 split_config.zh.apk
:/data/local/tmp # rm split_config.armeabi_v7a.apk split_config.x86.apk split_config.x86_64.apk
:/data/local/tmp # pm install *apk
Success

@ImranR98 ImranR98 added the installer This bug/feature is about how apps are installed label Feb 15, 2024
@ImranR98 ImranR98 mentioned this issue Mar 2, 2024
@AGuyNamedJens
Copy link

Can confirm, trying to install the MediaMarkt Deutschland and Saturn apps, crash immediately on start..

@Senliast
Copy link

Senliast commented Sep 1, 2024

I tried with a few apps with apks format and even on different devices and it doesn't work for any such app. It always says "unable to parse apk (incompatible or partial download)". For example, https://apkpure.net/de/netflix/com.netflix.mediaclient .

Screenshot_20240901-121835_Obtainium

@Senliast
Copy link

Senliast commented Sep 1, 2024

And when installing APKs from uptodown for example, the same happens. So i think Obtainium has generally a problem with installing APKs / XAPK.

@c3t1nn
Copy link

c3t1nn commented Oct 28, 2024

can confrim same goes for discord xapk from uptodown
photo_5836729245685105825_w

@qwyop
Copy link

qwyop commented Nov 2, 2024

https://apkpure.com/how-to/how-to-install-xapk-apk
Screenshot_20241102-051639 APKPure page on how to install XAPK files says XAPK files cannot be installed with the phone's default installer, requiring installation of APKPure's XAPK Installer (or others listed in https://fileinfo.com/extension/xapk)

I think XAPKs don't currently work in Obtainium, as the APKPure app I was using changed from APK to XAPK in the latest version (https://apkpure.com/エイリアンのたまご-放置系バトル育成rpgゲームアプリ/com.paondp.game2.padp.etg/download/1.35.4 vs https://apkpure.com/エイリアンのたまご-放置系バトル育成rpgゲームアプリ/com.paondp.game2.padp.etg/download/1.35.3), and gives me this error when attempting to update to it
Screenshot_20241101-172038_Obtainium "Could not get ID from APK" error

@DarkCrypt
Copy link

@ImranR98
Not being able to install XAPKs appears to be a continuously growing issue. Some don't install because of incomplete files while others install perfectly outside of Obtainium. Of course there's no fix for incomplete files but there should still be a way for Obtainium to handle installing complete XAPKs.

So far the only "working" solution I found is almost 2yrs old which could be irrelevant now. Still be worth checking out: https://stackoverflow.com/a/75118149.

Another option could be to add a selector within Obtainium's Settings for users to choose a different APK/XAPK installer instead of the default installer. There would be plenty to choose from if this is possible.

@jm355
Copy link

jm355 commented Nov 14, 2024

https://github.com/SmartPack/PackageManager handles xapks apparently, that may also be a good reference, or maybe the dev @sunilpaulmathew may be willing to help?

Edit: looks like package manager has you manually select the apk files within the xapk before installing, instead of automatically selecting the right ones for your device architecture, language, and dpi. The stackoverflow one doesn't seem to try to filter anything out of the xapk, it just installs everything in it. But, it looks like it'd be relatively easy to add filtering as long as the device dpi architecture, and enabled languages can be retrieved

@jm355
Copy link

jm355 commented Nov 14, 2024

looks like the xapk contents might be getting loaded here, so maybe this is where to add filtering to only get the apks in the xapk that the device needs, if filtering is enabled?

@jm355
Copy link

jm355 commented Nov 18, 2024

https://garmin-explore.en.uptodown.com/android/download latest version updated with no problem

@DarkCrypt
Copy link

https://garmin-explore.en.uptodown.com/android/download latest version updated with no problem

The latest version is an APK.


So far I've tried 6 different apps that can install XAPKs. APKPure, Apktool M, App Manager, MiXplorer, Package Manager, and Uptodown.

APKPure, MiXplorer, and Uptodown installs the entire XAPK. (No selection provided)

Apktool M and App Manager automatically selects the device architecture, language, and dpi.

Package Manager requires manual selection of the device architecture, language, and dpi as stated above. (The app also doesn't show up when selecting the XAPK to install from file manager)

*I'm not sure how difficult it is to cross reference Dart and Java but App Manager is probably the best option. App Manager is also where I got the idea for users to choose a different APK/XAPK installer instead of the default installer.

@DarkCrypt
Copy link

I just noticed there's multiple issues requesting a different APK installer, mostly for App Manager.

Discussions about this should be moved to issue #517.

This issue also explains that this was possible in previous versions of Obtainium and why it's not now.

@1xFF
Copy link
Contributor

1xFF commented Nov 22, 2024

The issue here seems to be that Obtainium does not support split apks, android_package_installer does not have any method to do so. The native PackageInstaller will likely have to be used to properly stage the installation.

@ImranR98
Copy link
Owner

Minor update: Took some time to look into this. Apparently it's not enough to just unzip an XAPK and try to install each APK you find inside (which is what Obtainium tries to do). Instead you have to figure out which APKs to install by reading the JSON that's included in the XAPK, then somehow "commit" them to the installer session, then tell it to install (you can't install each one separately).

The PackageManager app does something similar here: SmartPack/PackageManager@18db3ec#diff-342421a6cbed575b8f99405be8654a345981d7aa0a5231a8645bcd62ca3a3047R322

Obtainium currently uses a fork of the android_package_installer Flutter plugin to do installs. It's probably possible to add XAPK support to it (somewhere here but I haven't tried yet.

@ImranR98 ImranR98 changed the title Updating from apkpure fails for certain apps (others work): XAPK Support Nov 23, 2024
@ImranR98 ImranR98 added high priority This issue is a high priority TODO Issue to focus on for the next release labels Nov 23, 2024
@ImranR98 ImranR98 pinned this issue Nov 23, 2024
@1xFF
Copy link
Contributor

1xFF commented Nov 23, 2024

The original implementation I saw that tipped me off was from SAI:
https://github.com/Aefyr/SAI/blob/55505d231b1390e824d1cc0c8f4fa35fd4677105/app/src/main/java/com/aefyr/sai/installer/rootless/RootlessSAIPackageInstaller.java#L88

Staging the APK's like that does not seem too difficult, but I can't find much about the JSON files you are refering too.
This site states that its called manifest.json, yet that doesn't appear in the discord XAPK from uptodown that a c3t1nn tried downloading.

@ImranR98
Copy link
Owner

ImranR98 commented Nov 23, 2024

Yes, I'm referring to manifest.json which does appear in the Garmin Explore XAPK. I'm guessing that if the file is not there, all APKs are supposed to be installed.

Edit: I was wrong - the Garmin XAPK doesn't have a manifest JSON either. It looks like files from Uptodown don't have it but files from APKPure do.

@jm355
Copy link

jm355 commented Nov 23, 2024

In the absence of a manifest.json, it may make sense to try to filter the architecture, dpi, and language by filename, or have an option to do so

ImranR98 added a commit that referenced this issue Nov 23, 2024
ImranR98 added a commit that referenced this issue Nov 23, 2024
ImranR98 added a commit that referenced this issue Nov 23, 2024
- Improved XAPK Support (#682)
- Custom user-agent for APKMirror (as per feedback in #1973)
- Minor change to German translation (#1986)
@ImranR98
Copy link
Owner

I have updated the plugin to support multiple APKs in one session. The latest release of Obtainium uses this to just install everything inside the XAPK. This is a very quick and dirty approach which is not very efficient and will probably fail in many cases (so I'm leaving this issue open), but it does work for Discord (from APKPure) and Garmin Explore (from Uptodown) at least on my device.

@ImranR98 ImranR98 removed the TODO Issue to focus on for the next release label Nov 23, 2024
@ImranR98
Copy link
Owner

Improvements to make:

  • Figure out what the base APK is for sources where we don't have an app ID in advance.
  • Figure out what non-base APKs are needed (based on device architecture, language, and screen resolution) and only install those.

Please report any cases where installation still fails.

@ArnoldSmith86
Copy link
Author

For https://discord-chat-for-gamers.en.uptodown.com/android the last version Obtanium was able to install was 244.13. Not sure if I had to fix that one afterwards but since then it didn't even try. It says:

2024-11-24 00:08:19.626: info: Could not install APKs from XAPK: The APK could not be parsed (incompatible or partial download)
2024-11-24 00:08:19.627: error: The APK could not be parsed (incompatible or partial download) [Discord] [Discord]

That test was with Obtainium 1.1.32.

LineageOS 19 (Android 12) on OnePlus 5T without Play services.

@ImranR98
Copy link
Owner

Hmm, the Discord XAPK from Uptodown has no manifest JSON, nor a base com.discord.apk file. Instead it has a large number of APKs with seemingly random names. Not sure how to parse that.

@ArnoldSmith86
Copy link
Author

When in doubt, just install all the things? I don't know. It's pretty wild to me how inconsistent all of this is (Android packaging, not Obtanium)...

@jm355
Copy link

jm355 commented Nov 25, 2024

Weird change: https://symfonium.en.uptodown.com/android/download has a .nov 25, 2024 extension. When I renamed it to .xapk it opened and installed in app manager fine. Looks like maybe they forgot to add .xapk to the extension? But obtainium failed to install it

@1xFF
Copy link
Contributor

1xFF commented Nov 26, 2024

I've partially reversed engineered how SAI handles these XAPK's. The split APKs from uptodown have to be parsed by their AndroidManifest.xml.
Because the manifest is in the AXML format it needs to be decoded, SAI does this my using this AOSP library at this part of the code
Once you have the manifest, you can figure out what the APK is for with the split and android:splitTypes keys.

For example, discords f4e7332184f7c31e8ad65489624eeeaf7a1f5410c4a8dc41f51517914bfbec41.apk is:

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:splitTypes="base__density" package="com.discord" split="config.hdpi">
    <application android:extractNativeLibs="false" android:hasCode="false">
        <meta-data android:name="com.android.vending.derived.apk.id" android:value="2"/>
    </application>
</manifest>

Unfortunately when working with flutter plugins, every single of my IDE's has an issue providing even the most basic of language support. So I'm not sure when or even if I could provide a PR

@ImranR98
Copy link
Owner

@1xFF I use VSCodium with the Flutter/Dart plugins from 'Dart Code' if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority This issue is a high priority installer This bug/feature is about how apps are installed
Projects
None yet
Development

No branches or pull requests