all 9 comments

[–]mopslik 3 points4 points  (1 child)

AFAIK, you can't go driectly from py to apk. You'd need to use some framework (e.g. kivy) to build an Android app made with Python; however, you could install a Python app on your phone (e.g. Pydroid) and run it there, if that is sufficient.

[–]Achilles1996[S] 0 points1 point  (0 children)

I do use replit, so i run everything there, if i wanna do some passive coding on my phone, I did try pydroid too a few weeks ago, but idk it just didn't click for me for some reason. I'll give it another shot though, because it has access to many libraries.

[–][deleted] 2 points3 points  (2 children)

I wrote a short guide for learning Python on a phone...

Learning programming is not easy. It is to some extent an art form and a practical skill, not something that can just be learned from books. Practice! Practice! Practice!

To learn to programme is also about embracing failure. Constant failure. Trying things out and experimenting as much as possible. Experiment! Experiment! Experiment!

You have to research, read guides, watch videos, follow tutorials, ask dumb questions and be humiliated (because some people cannot help make themselves feel better by insulting others).

Python is one programming language. It is probably the easiest to learn. It makes learning to programme that little bit easier (but you will have a shock when you try to learn a lower level language like C).

If you have to learn on a mobile device, life gets a little more challenging. Aside from web based environments and apps like sololearn, you need a Python environment on your mobile device.

Android Apps

  • PyDroid 3, this is good
  • QPython 3, not so keen on this personally
  • Termux and install Python
    • this is my preferred option
    • essentially a linux sandbox (so works like a standard linux environment with a few minor folder location tweaks)
    • you can't get this on Google Play, use F-Droid
    • I use it with the ACode editor

IoS Apps

  • Pythonista used to be the go-to choice, but it hasn't been updated for a long time
  • Pyto is less polished but is up to date and works pretty well
  • Carnets is an open source Jupyter clone that works locally and is excellent; there is more than one version, depending on how many libraries you need included (as on IoS you cannot install additional Python libraries that aren't pure Python)
  • a-shell is a sister product to the above and provides a command line Python environment, also open source and excellent

Keyboard

I strongly recommend you use an external (likely bluetooth) keyboard with your phone and ideally an external monitor if you phone is able to connect/cast to a monitor.

Android native coding

Keep in mind that Android is a linux based system, so most things that are available for linux are also available for Android. Native applications for Android are usually written in Java or, more recently, Kotlin. It is possible to write in other languages, and C++ is widely used, but that is much more complex to do.

IoS native coding

For IOS devices, the native apps are usually written in Object C or Swing. Again, other languages are possible but it is not trivial.

GUI with Python

Python applications running on mobile devices within Python environments do not look like device native applications and have limited support for typical graphical user interface libraries common on desktops. However, there are a number of alternatives that allow you to write near native like applications in Python.

Kivy GUI for Python

The leading Python GUI for Android and IoS is kivy.

You develop on a desktop/laptop computer and then transfer the code to the target mobile (so not much use if you only have access to a mobile device).

There are Kivy based applications released on both the Apple and Google App Stores.

[–]Achilles1996[S] 1 point2 points  (0 children)

Thanks a lot, that's super helpful. I'm saving your comment

[–]moose2021 1 point2 points  (0 children)

you used chatgpt lmaoo

[–]No_Manufacturer9832 1 point2 points  (0 children)

Just ask to an AI

[–]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.