import gradio as gr import subprocess import os import shutil import re def fix_apk(apk_file): if apk_file is None: return "لطفاً یک فایل انتخاب کنید.", None apk_path = apk_file.name output_dir = "extracted_apk" # پاکسازی فایل‌های قدیمی if os.path.exists(output_dir): shutil.rmtree(output_dir) if os.path.exists("fixed.apk"): os.remove("fixed.apk") if os.path.exists("final_signed_game.apk"): os.remove("final_signed_game.apk") try: # مرحله ۱: باز کردن فایل subprocess.run(["apktool", "d", apk_path, "-o", output_dir, "-f"], check=True) # مرحله ۲: ویرایش کدهای اندروید ۱۴ و ۱۵ manifest_path = os.path.join(output_dir, "AndroidManifest.xml") with open(manifest_path, "r", encoding="utf-8") as f: manifest = f.read() manifest = re.sub(r'targetSdkVersion="[0-9]+"', 'targetSdkVersion="34"', manifest) manifest = manifest.replace('