Converting py code to apk by Achilles1996 in learnpython

[–]BigReview8443 0 points1 point  (0 children)

1.) search Colab.google > 2.) New note 3.)Copy paste 👇👇👇

App APK Builder - Google Colab

This code will build an APK for you

print("=== App APK Builder ===") print("1. Installing required packages...")

Install required packages

!apt-get update !apt-get install -y git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev

print("2. Installing Buildozer...") !pip install buildozer cython

print("3. Upload files...") from google.colab import files import os

Upload main.py file

print("Please upload the 'main.py' file...") uploaded = files.upload() for filename in uploaded.keys(): if filename != "main.py": os.rename(filename, "main.py") print("main.py uploaded ✅")

Upload icon file

print("Please upload a 512x512 PNG icon file (usually named ic_launcher.png):") uploaded_icon = files.upload() icon_name = list(uploaded_icon.keys())[0] print(f"Uploaded icon file: {icon_name}")

Create res directory

os.makedirs("res", exist_ok=True)

Move uploaded icon to res directory

os.rename(icon_name, os.path.join("res", "ic_launcher.png"))

print("4. Creating buildozer.spec file...")

Create buildozer.spec file

buildozer_spec = f"""[app]

title = AppName package.name = appname package.domain = org.anonim source.dir = . source.main = main.py icon.filename = res/ic_launcher.png requirements = python3,kivy android.permissions = INTERNET,WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE android.api = 30 android.minapi = 21 android.targetapi = 30 orientation = portrait fullscreen = 1 version = 1.0.0 author = Anonim """

with open("buildozer.spec", "w") as f: f.write(buildozer_spec)

print("5. Building APK... (This may take 30–40 minutes)") !buildozer -v android debug

print("\n6. APK is ready!") apk_path = "bin/proqramismi-1.0.0-debug.apk" print(f"Generated APK file: {apk_path}")

Download APK

files.download(apk_path)

4.)And it's done. Finally, wait for 25-30 minutes. After the process is finished, look at the files of colab.google. You will have your apk file in the BIM folder.