fieryhenry / tbcml

A python library designed to make modding The Battle Cats easier, more automated, and more powerful
MIT License
7 stars 3 forks source link

Trouble on Android #16

Open MrNooberDude opened 3 months ago

MrNooberDude commented 3 months ago

Tried putting in this script: from tbcml.core import ( CountryCode, GameVersion, Apk, GamePacks, Mod, ModEdit, CatFormType, Cat, CatForm, )

cc = CountryCode.EN

gv = GameVersion.from_string("12.3.0")

apk = Apk(gv, cc) apk.download() apk.extract()

apk.download_server_files() apk.copy_server_files()

game_packs = GamePacks.from_apk(apk)

mod_id = Mod.create_mod_id()

mod = Mod( name="Test Mod", author="Test Author", description="Test Description", mod_id=mod_id, mod_version="1.0.0", password="test", )

cat_id = 0 cat_form_type = CatFormType.FIRST

form = CatForm(cat_id, cat_form_type, name="Test Cat")

cat = Cat(cat_id)

cat.set_form(cat_form_type, form)

mod_edit = ModEdit(["cats", cat_id], cat.to_dict())

mod.add_mod_edit(mod_edit)

apk.load_mods([mod], game_packs)

print(apk.get_final_apk_path())

and ended with this in Termux: Traceback (most recent call last): File "/storage/emulated/0/download/bcml/script.py", line 1, in from tbcml.core import ( File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/tbcml/init.py", line 1, in from tbcml import core File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/tbcml/core/init.py", line 111, in from .io.bc_csv import CSV, Delimeter, to_str File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/tbcml/core/io/init.py", line 1, in from tbcml.core.io import ( File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/tbcml/core/io/bc_image.py", line 4, in from PyQt5.QtGui import QImage, QIcon, QPixmap ModuleNotFoundError: No module named 'PyQt5'

fieryhenry commented 3 months ago

Can you try installing from source: https://github.com/fieryhenry/tbcml#from-source, and if that doesn't work try using the new-structure branch: https://github.com/fieryhenry/tbcml/tree/new-structure#from-source-recommended

MrNooberDude commented 3 months ago

Will do!

MrNooberDude commented 3 months ago

Got the apk downloaded this time! This is what it output though: Traceback (most recent call last): File "/storage/emulated/0/download/bcml/script.py", line 26, in <module> apk.copy_server_files() ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Apk' object has no attribute 'copy_server_files'

fieryhenry commented 3 months ago

sorry, i forgot to update the readme when i removed that function. You should just be able to delete that line from the script apk.copy_server_files()

MrNooberDude commented 3 months ago

So the script seems to be fine now, but it can't sign the APK I think Failed to pack APK: I: Using Apktool 2.9.1 I: Checking whether resources has changed... I: Building resources... brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/data/data/com.termux/files/usr/tmp/brut_util_Jar_91658046131707131065907225576027859682.tmp, compile, --dir, /data/data/com.termux/files/home/Documents/tbcml/APKs/12.3.0en/extracted/res, --legacy, -o, /data/data/com.termux/files/home/Documents/tbcml/APKs/12.3.0en/extracted/build/resources.zip] W: /data/data/com.termux/files/usr/tmp/brut_util_Jar_91658046131707131065907225576027859682.tmp[235]: syntax error: unexpected '('

Traceback (most recent call last): File "/storage/emulated/0/download/bcml/script.py", line 63, in apk.load_mods([mod], game_packs) File "/storage/emulated/0/download/bcml/tbcml/src/tbcml/core/io/apk.py", line 1345, in load_mods self.load_packs_into_game(game_packs) File "/storage/emulated/0/download/bcml/tbcml/src/tbcml/core/io/apk.py", line 373, in load_packs_into_game self.sign() File "/storage/emulated/0/download/bcml/tbcml/src/tbcml/core/io/apk.py", line 270, in sign self.zip_align() File "/storage/emulated/0/download/bcml/tbcml/src/tbcml/core/io/apk.py", line 314, in zip_align apk_path.copy(self.final_apk_path) File "/storage/emulated/0/download/bcml/tbcml/src/tbcml/core/io/path.py", line 198, in copy raise FileNotFoundError(f"File not found: {self.path}") FileNotFoundError: File not found: /data/data/com.termux/files/home/Documents/tbcml/APKs/12.3.0en/jp.co.ponos.battlecatsen-modded-aligned.apk

fieryhenry commented 3 months ago

seems like maybe the architecture you are using isn't supported by apktool unfortunately: https://github.com/iBotPeaches/Apktool/issues/2407 and https://github.com/iBotPeaches/Apktool/issues/3498. I don't know if there is a way to fix it, i'll have to modify the library to use something other than apktool when apktool doesn't work

MrNooberDude commented 3 months ago

Maybe I could try overriding the downloaded one with of a different architecture. Would I just delete the apk.download_server_files() line and put it in the directory they usually are in?

fieryhenry commented 3 months ago

it's the architecture of your device that's the problem, not the architecture of the apk

MrNooberDude commented 3 months ago

Oooohhh, okay.