Coder Social home page Coder Social logo

luigivampa92 / xapk-to-apk Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 2.0 10 KB

A simple standalone python script that converts .xapk file into a normal universal .apk file

Home Page: https://github.com/LuigiVampa92/xapk-to-apk

License: MIT License

Python 100.00%
android apk apktool convert converter transform xapk

xapk-to-apk's Introduction

XapkToApk

A simple standalone Python script with no extra library dependencies that converts the .xapk file into a normal .apk file.

Usage

The usage is very simple.

First, clone the repo and make sure the script has execution permission:

git clone https://github.com/LuigiVampa92/xapk-to-apk
cd xapk-to-apk
chmod +x xapktoapk.py

Get your .xapk file ready, put it near the script, and execute the script:

python xapktoapk.py application.xapk

You can put the symlink to this script into the path. Like this (the absolute path to the script depends on your OS and home directory settings):

ln -s /home/username/github/xapk-to-apk/xapktoapk.py /usr/local/bin/xapktoapk

After that, the script can be executed from any directory, like this:

xapktoapk application.xapk

The result apk file application.apk will be placed next to your xapk file, in the same directory.

Requirements

You do not need any Python dependencies to run the script; however, you MUST have some tools installed in your OS, and paths to their executable MUST be set to the $PATH environment variable. The script relies on that.

These tools are apktool, zipalign and apksigner.

apktool can be installed via your OS package manager: apt, brew, whatever, or pulled directly from GitHub. zipalign and apksigner are part of the Android SDK build-tools distribution and must be installed via sdkmanager in Android Studio or via CLI.

Do not forget to make symlinks of these tools to the system's $PATH environment variable, OR add the entire build-tools directory to it.

Signing the result apk

Since repackaging the splitted app bundle into the universal apk requires changing the original app's manifest file, the original signature will be broken, and the app must be resigned before you can install it on a real device.

The easiest way to do it is to create an xapktoapk.sign.properties file with the values of your keystore file (see xapktoapk.sign.properties.example for an example). This file must be placed in the same directory with xapktoapk.py script, OR you can put it in your user home directory (~). This way, repacked apk files will be signed automatically.

If you don't want to create a dedicated keystore to sign the result apk files, you can use your default Android SDK debug keystore. In this case, the contents of the xapktoapk.sign.properties file should look like this:

sign.enabled=true
sign.keystore.file=/home/username/.android/debug.keystore 
sign.keystore.password=android
sign.key.alias=androiddebugkey
sign.key.password=android

The sign.keystore.file value in the example above is for Linux. Set the absolute path according to your OS and system user name.

By default, the resigning of the result apk files is disabled. If you do not want to sign it automatically, you don't have to do it. You can just sign the apk file manually after the conversion is completed.

xapk-to-apk's People

Contributors

luigivampa92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ohyeah521 w41g87

xapk-to-apk's Issues

Exception: failed to pack apk

Windows 10 using WSL2. Debian.
Successfully installed & tested these tools python3, apktool, zipalign and apksigner.
Successfully generated a xapktoapk.sign.properties file with default Android SDK debug keystore.
Test apk is AI_Bubble_GPT_chat_in_any_app.xapk [Package ID: the.bravenewworld.input]

┌──(username㉿DESKTOP)-[~/xapk-to-apk]
└─$ python3 xapktoapk.py test.xapk
[*] start
[*] unpacking xapk
[*] xapk file unpacked. 3 parts discovered
[*] unpacking 1 of 3
[*] unpacking 2 of 3
[*] unpacking 3 of 3
[*] repack apk
Traceback (most recent call last):
  File "/home/username/xapk-to-apk/xapktoapk.py", line 588, in <module>
    main()
  File "/home/username/xapk-to-apk/xapktoapk.py", line 579, in main
    build_single_apk(path_dir_tmp, apk_main['apk_dir_path'], should_sign_apk, sign_properties)
  File "/home/username/xapk-to-apk/xapktoapk.py", line 439, in build_single_apk
    pack_apk(path_to_tmp_dir, path_to_main_apk_dir)
  File "/home/username/xapk-to-apk/xapktoapk.py", line 318, in pack_apk
    raise Exception("failed to pack apk")
Exception: failed to pack apk

┌──(username㉿DESKTOP)-[~/xapk-to-apk]
└─$

Investiaging manually...

└─$ apktool b ./.xapktoapk/the.bravenewworld.input
I: Using Apktool 2.7.0-dirty
I: Checking whether resources has changed...
I: Building resources...
W: aapt: brut.common.BrutException: brut.common.BrutException: Could not extract resource: /prebuilt/linux/aapt_64 (defaulting to $PATH binary)
W: res/drawable/$avd_hide_password__0.xml: Invalid file name: must contain only [a-z0-9_.]
W: res/drawable/$avd_hide_password__1.xml: Invalid file name: must contain only [a-z0-9_.]
W: res/drawable/$avd_hide_password__2.xml: Invalid file name: must contain only [a-z0-9_.]
W: res/drawable/$avd_show_password__0.xml: Invalid file name: must contain only [a-z0-9_.]
W: res/drawable/$avd_show_password__1.xml: Invalid file name: must contain only [a-z0-9_.]
W: res/drawable/$avd_show_password__2.xml: Invalid file name: must contain only [a-z0-9_.]
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [aapt, p, --min-sdk-version, 23, --target-sdk-version, 33, --version-code, 112401470, --version-name, 0.0.2, --no-version-vectors, -F, /tmp/APKTOOL6790195097454407399.tmp, -0, META-INF/androidx.activity_activity.version, -0, META-INF/androidx.annotation_annotation-experimental.version, -0, META-INF/androidx.appcompat_appcompat-resources.version, -0, META-INF/androidx.appcompat_appcompat.version, -0, META-INF/androidx.arch.core_core-runtime.version, -0, META-INF/androidx.asynclayoutinflater_asynclayoutinflater.version, -0, META-INF/androidx.browser_browser.version, -0, META-INF/androidx.cardview_cardview.version, -0, META-INF/androidx.coordinatorlayout_coordinatorlayout.version, -0, META-INF/androidx.core_core-ktx.version, -0, META-INF/androidx.core_core.version, -0, META-INF/androidx.cursoradapter_cursoradapter.version, -0, META-INF/androidx.customview_customview.version, -0, META-INF/androidx.databinding_baseAdapters.version, -0, META-INF/androidx.databinding_databindingKtx.version, -0, META-INF/androidx.databinding_library.version, -0, META-INF/androidx.databinding_viewbinding.version, -0, META-INF/androidx.documentfile_documentfile.version, -0, META-INF/androidx.drawerlayout_drawerlayout.version, -0, META-INF/androidx.dynamicanimation_dynamicanimation-ktx.version, -0, META-INF/androidx.dynamicanimation_dynamicanimation.version, -0, META-INF/androidx.emoji2_emoji2-views-helper.version, -0, META-INF/androidx.emoji2_emoji2.version, -0, META-INF/androidx.fragment_fragment.version, -0, META-INF/androidx.interpolator_interpolator.version, -0, META-INF/androidx.legacy_legacy-support-core-ui.version, -0, META-INF/androidx.legacy_legacy-support-core-utils.version, -0, META-INF/androidx.legacy_legacy-support-v4.version, -0, META-INF/androidx.lifecycle_lifecycle-livedata-core.version, -0, META-INF/androidx.lifecycle_lifecycle-livedata.version, -0, META-INF/androidx.lifecycle_lifecycle-process.version, -0, META-INF/androidx.lifecycle_lifecycle-runtime-ktx.version, -0, META-INF/androidx.lifecycle_lifecycle-runtime.version, -0, META-INF/androidx.lifecycle_lifecycle-service.version, -0, META-INF/androidx.lifecycle_lifecycle-viewmodel-savedstate.version, -0, META-INF/androidx.lifecycle_lifecycle-viewmodel.version, -0, META-INF/androidx.loader_loader.version, -0, META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version, -0, META-INF/androidx.media_media.version, -0, META-INF/androidx.palette_palette-ktx.version, -0, META-INF/androidx.palette_palette.version, -0, META-INF/androidx.print_print.version, -0, META-INF/androidx.recyclerview_recyclerview.version, -0, META-INF/androidx.savedstate_savedstate.version, -0, META-INF/androidx.slidingpanelayout_slidingpanelayout.version, -0, META-INF/androidx.startup_startup-runtime.version, -0, META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version, -0, META-INF/androidx.tracing_tracing.version, -0, META-INF/androidx.transition_transition.version, -0, META-INF/androidx.vectordrawable_vectordrawable-animated.version, -0, META-INF/androidx.vectordrawable_vectordrawable.version, -0, META-INF/androidx.versionedparcelable_versionedparcelable.version, -0, META-INF/androidx.viewpager2_viewpager2.version, -0, META-INF/androidx.viewpager_viewpager.version, -0, META-INF/com.google.android.material_material.version, -0, META-INF/kotlinx_coroutines_android.version, -0, META-INF/kotlinx_coroutines_core.version, -0, META-INF/kotlinx_coroutines_reactive.version, -0, META-INF/kotlinx_coroutines_rx2.version, -0, META-INF/services/b9.j, -0, META-INF/services/w6.a, -0, META-INF/services/z8.v, -0, assets/8tbwIQXSNUSMQhWn, -0, assets/KbXRbmtJ3f9m519J, -0, assets/Luwdc4TYjP78oRNg, -0, assets/S19L1LahWq6tnmND, -0, assets/XmTgGK507eKb7IBA, -0, assets/ZZjAy1cir9hIGgJA, -0, assets/m0KIuxpr0lwT9fqv, -0, lib/arm64-v8a/libmmkv.so, -0, lib/arm64-v8a/libpairipcore.so, -0, res/mipmap-hdpi/ic_default.webp, -0, res/mipmap-mdpi/ic_default.webp, -0, res/mipmap-xhdpi/ic_default.webp, -0, res/mipmap-xxhdpi/ic_default.webp, -0, res/mipmap-xxxhdpi/ic_default.webp, -0, resources.arsc, -0, webp, -0, res/mipmap-xxxhdpi/ic_default.webp, -0, arsc, -I, /home/username/.local/share/apktool/framework/1.apk, -S, /home/username/xapk-to-apk/./.xapktoapk/the.bravenewworld.input/res, -M, /home/username/xapk-to-apk/./.xapktoapk/the.bravenewworld.input/AndroidManifest.xml]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.