Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:52
    loserq commented #2680
  • 12:47
    loserq commented #2680
  • Oct 15 15:31
    hosseinkhojany opened #2680
  • Oct 14 17:08
    pashamcr commented #2675
  • Oct 14 16:32
    pashamcr commented #2675
  • Oct 14 16:31
    pashamcr commented #2675
  • Oct 14 06:25
    pashamcr edited #2675
  • Oct 13 20:14
    MrIkso commented #2650
  • Oct 13 20:14
    MrIkso synchronize #2650
  • Oct 13 14:39
    loserq opened #2679
  • Oct 13 10:35
    iBotPeaches closed #2677
  • Oct 13 10:35
    iBotPeaches commented #2677
  • Oct 13 10:30
    iBotPeaches closed #2678
  • Oct 13 10:30
    iBotPeaches commented #2678
  • Oct 13 10:22
    hosseinkhojany opened #2678
  • Oct 11 17:34
    pashamcr commented #2675
  • Oct 11 17:33
    pashamcr commented #2675
  • Oct 11 15:14
    pashamcr commented #2675
  • Oct 11 15:08
    pashamcr commented #2675
  • Oct 11 14:50
    pashamcr commented #2675
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
If any actually qualified devs are out there, please do give random-access-exomemory a proper answer.
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Ah okay then, thanks!
And yeah the room seems pretty dead sadly
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Indeed 😔
But actually, that ELF: inaccessible or not found leads me to believe that it indeed may be an issue with Termux
Since, based on a quick Google search, that seems like an operating system reliant thing
Could maybe be worth a shot to ask in the Termux room
Since that room's comparatively way more active
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Alright then, thanks!
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
o7
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
I: Using Apktool 2.6.0
I: Checking whether sources has changed...                                  I: Checking whether sources has changed...                                  I: Checking whether sources has changed...                                  I: Checking whether resources has changed...                                I: Building resources...                                                    W: invalid resource directory name: /data/data/com.termux/files/home/discord-patcher/discord/res font                                                   brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/data/data/com.termux/files/usr/bin/aapt, p, --min-sdk-version, 21, --target-sdk-version, 29, --version-code, 89108, --version-name, 89.8 - Beta, --no-version-vectors, -F, /data/data/com.termux/files/usr/tmp/APKTOOL18005119699576679610.tmp, -0, resources.arsc, -0, png, -0, jpg, -0, mp3, -0, jpeg, -0, arsc, -I, /data/data/com.termux/files/home/.local/share/apktool/framework/1.apk, -S, /data/data/com.termux/files/home/discord-patcher/discord/res, -M, /data/data/com.termux/files/home/discord-patcher/discord/AndroidManifest.xml]
It's progress ¯\ _(ツ)_/¯
I cant figure out where the error is though
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
could it be that apktool doesn't like the space in the folder name of /data/data/com.termux/files/home/discord-patcher/discord/res font?
1 reply
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
random-access-exomemory
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
It's not a space
That's the issue
res/font is a valid folder, but whenever i try compiling it, it keeps trying to use res font
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
O
Bizarre
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Here's someone who had the same issue as you: iBotPeaches/Apktool#1787
But the dev couldn't reproduce the issue
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Thanks, I'm checking it out noq
Now*
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Wait, try doing --use-aapt2 when rebuilding
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
That flag apparently rebuilds the apk using a different method
So I think it's worth a shot
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Oh? Will try
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
Trying it now 👍
vincetheprogrammer same error :/
W: /data/data/com.termux/files/usr/tmp/brut_util_Jar_141041913573869719696425869119538060698.tmp[1]: ELF: inaccessible or not found
W: /data/data/com.termux/files/usr/tmp/brut_util_Jar_141041913573869719696425869119538060698.tmp[47]: syntax error: unexpected ')'
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/data/data/com.termux/files/usr/tmp/brut_util_Jar_141041913573869719696425869119538060698.tmp, compile, --dir, /data/data/com.termux/files/home/discord-patcher/discord/res, --legacy, -o, /data/data/com.termux/files/home/discord-patcher/discord/build/resources.zip]
vincetheprogrammer
@vincetheprogrammer:matrix.org
[m]
Snowfall
Yes
Lol
But hmm, isn't that the same as the first error you got?
random-access-exomemory
@random-access-exomemory:matrix.org
[m]
It is
Hold on, let me get the code for what I'm doing
(It's all handled in a python script)
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