Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 04 01:17
    iBotPeaches commented #2701
  • Dec 04 01:16
    Rone-s9 commented #2701
  • Dec 03 06:25
    sriteja777 commented #2709
  • Dec 02 20:49
    JoeyRosicka opened #2712
  • Dec 01 23:35
    Liquidbone opened #2711
  • Nov 30 17:18
    iBotPeaches closed #2710
  • Nov 30 17:18
    iBotPeaches commented #2710
  • Nov 30 16:26
    gorwhh opened #2710
  • Nov 30 16:24
    gorwhh commented #2704
  • Nov 29 20:39
    sriteja777 edited #2709
  • Nov 29 20:33
    sriteja777 opened #2709
  • Nov 29 19:47
    EthecRaz commented #2407
  • Nov 29 16:50
    jpstotz commented #1460
  • Nov 29 16:48
    KarmaMod commented #1460
  • Nov 29 16:41
    KarmaMod commented #2657
  • Nov 29 16:41
    KarmaMod closed #2657
  • Nov 29 10:24
    kaan-celen commented #1129
  • Nov 29 00:38
    iBotPeaches commented #2704
  • Nov 28 23:40
    worshiplove commented #2704
  • Nov 27 14:02
    jpstotz commented #2697
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Okie
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
#!/usr/bin/python3

from os import walk, path, chdir, system
from json import load as jload

with open('settings.json') as f:
    config = jload(f)

print("Downloading `discord.apk`....")
code = system(f'wget {config["download_url"]} -O discord.apk -o download.log')
if code != 0:
    print("Something went wrong while downloading the file, check `download.log`")
    raise SystemExit(code)
print("APK downloaded\nDecompiling APK...")
if not config['package_name']:
    system('apktool d -r discord.apk')
else:
    print(f"Custom package name will be `{config['package_name']}`. This may take longer to decompile and build.")
    system('apktool d discord.apk')
chdir('discord')
print("\nDecompiled the apk, beginning patching process.")

# Things that need some renaming to actually work correctly should be edited and reviewed here every update
bugfixes = [
  ('res font', 'res/font'),
]

# Basic replacements throughout the code to replace discord routes with fosscord routes
# NOTE: Order of replacements is VERY important and will probably have to do stupid stuff to make it customisable
replacements = [
  ('https://cdn.discordapp.com', 'https://'+config['cdn_url']),
  ('https://gateway.discord.gg', 'https://'+config['gateway_url']),
  ('https://discord.com', 'https://'+config['base_url']), # discord.com to the base url of settungs.json
  ('https://discordapp.com', 'https://'+config['base_url']), # Extra change just in case discordapp is still used in the code somewhere
  ('https://discord.gg', 'https://'+config['invite_url']), # discord.gg to the invite url
]

if config.get('debug'):
    replacements.append(("DEBUG:Z = false", "DEBUG:Z = true")) # Enables debug if it's true in the config

# TODO: Potentially add support for patching files with .patch files?

system("mv AndroidManifest.xml ..")

def patch(folder):
    for root, _, files in walk(path.join('.', folder)):
        for file in files:
            fpath = path.join(root, file)
            try:
                with open(fpath) as f:
                    data = tmp = f.read()
                for bugfix in bugfixes:
                    data = data.replace(*bugfix)
                for replacement in replacements:
                    data = data.replace(*replacement)
                if tmp != data:
                    with open(fpath, 'w+') as f:
                        f.write(data)
                    print(f"Applied patches to `{fpath}`")
            except UnicodeDecodeError:
                pass

patch('smali')
patch('smali_classes2')
patch('smali_classes3')

system("mv ../AndroidManifest.xml .")

#if config['package_name']:
#   with open('AndroidManifest.xml') as f:
#        manifest = f.read()
#    manifest = manifest.replace(config['original_package_name'], config['package_name'])
#    print("Applied patches to `AndroidManifest.xml`")
print("\nFinished applying patches\n\nRecompiling APK...")
chdir('..')
system('apktool b --use-aapt2 discord/ -o fosscord.unsigned.apk')
print("\nRecompiled APK.\nChecking if keystore exists...")
if not path.exists('keystore.jks'):
    print("\nNo keystore exists, creating one...")
    system('keytool -genkey -v -keystore keystore.jks -keyalg RSA -keysize 2048 -validity 10000')
print("\nSigning APK...")
system('apksigner sign --ks keystore.jks --out fosscord.signed.apk fosscord.unsigned.apk')
print("\nFinished signing the APK, the APK's name is `fosscord.signed.apk`.")
apktool b --use-aapt2 discord/ -o fosscord.unsigned.apk
That's the issue it seems like, but i don't know why it happens
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Most of that code went over my head unfortunately. I'm not too experienced at programming yet, but one other flag you can try maybe is --no-crunch. It apparently disables crunching of resource files (whatever that means). Beyond that, I don't think I'll be able to help you unfortunately. 😔
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
That's fair lol
Thanks anyway though, i appreciate you just trying to help me lol
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Yeah, np comrade
You could try pinging the dev maybe
He might have the channel set to only mentions or something
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
I'll ping them if this still doesn't work lol
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Kk
Good luck o7
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
They patch the discord apk on the device
I don't think they use apktool, but they just recompile the classes.dex with some changes
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
:o
Poggers
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Yeah lol
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
I'll check it out
Thanks bro
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Nice! Have fun and good luck!
No worries haha
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
o7
Gregory Klyushnikov
@grishk:matrix.org
[m]
ok so I don't really have anything to do, let me try to figure out why iBotPeaches/Apktool#2670 happens, these facebook apks are really something special but I want reactions on messages in my patched instagram build
Gregory Klyushnikov
@grishk:matrix.org
[m]
actually, I found the dumbest workaround:
  • decompile with --no-res
  • extract the r/ directory from the apk manually and put it into unknown/ inside the decompiled project
  • add all the files into unknownFiles in apktool.yml
  • then it builds...
the manual steps are needed because apktool expects resources to be under res/
yes I can confirm that the resulting apk works fine and does find all its resources, still, this is suboptimal, but it'll do for "I need to patch a more modern version of instagram right now" 🤣
DangerD1024
@DangerD1024
Hi there, is there any way to add some update module for decompiled app to make automated check for updates?
Arun
@arun54321
Can apktool compile android 12 apks properly? Whenever I recompile latest pixel launcher, I get parsing error. I had to replace androidmanifest.xml with original one to get apk working properly.
Arun
@arun54321
also I get error "Failure [INSTALL_FAILED_INTERNAL_ERROR: Failed to extract native libraries, res=-110]" when installing recompiled apk. for example apk from here -
https://github.com/LawnchairLauncher/lawnchair/actions/runs/1401503945
James Welchman
@JamesWelchman

Hey there - I'm a software engineer but an an android noob. I have errors with apktool and looking for some help.

After building an APK with apktool I get this error on installation: [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]

The steps to reproduce are here: https://stackoverflow.com/questions/69840918/how-to-pull-decompress-sign-build-and-install-apk-file-with-native-libraries