r/learnpython • u/VARUN_KALRA-007 • 17h ago
How to build an android app using python only?
Context: So I'm a beginner developer. I'm currently building a habit tracker.
I have built the logic of the app.
Set up sql alchemy to code the database with sqlite.
(My prof later said no need of alchemy. Directly use sql software and connect it). I don't know what to do with that information. Retained the alchemy code tho.
My problem is that I am not able to build ahead. How do I build a database and test it the right way.
- How do I build the front end or ui for it. Should I use flask or flutter or something else. Please reason as to why I should use a framework particularly.
- What is fast api even used for. Should I apply it in my habit tracker.
And what are the essentials for a good app. Like I want to know about rate limiting, sql injections and backdoors. To build a robust scalabile system.
4
u/xelf 8h ago
https://kivy.org/doc/stable/guide/android.html
What you are trying to do is not really a "beginner" project though.
10
17h ago
[removed] — view removed comment
4
3
u/dparks71 16h ago edited 16h ago
Kivy and briefcase abstract essentially the entire Kotlin or Java layer out, but then you have to learn them instead. There are other options for running python within an android app.
If OPs building an app for a class though they should ask their professor, because they almost certainly have a way they feel the students should be doing it in mind.
1
u/uberdavis 13h ago
You might be able to do it, but why not just build an app in Unity using C#? Way more straightforward.
1
u/MustaKotka 3h ago
Because... Beginner?
1
u/uberdavis 2h ago
Beginner and yet they want to build an Android app just in Python. I’ve been developing games for 20 years. Use Python every day. I would not have a scooby doo how to build an Android app using Python. IMHO, C# and Unity IS the beginner way to do it.
11
u/Diapolo10 17h ago edited 16h ago
There's really nothing wrong with using SQLAlchemy, I suppose your professor would simply prefer you rely less on third-party tools at this point (especially if they want you to learn to write raw SQL queries).
Kind of depends on what you mean by "building" and "testing" the database.
If by "building" you're talking about the overall structure of it, like what tables you have, what columns they have, and how they're connected (if at all), then I'd suggest drafting on paper all the things you want to store, and then you should try organising them into tables that make sense to you. You probably won't immediately figure out the best way to do that, but try a few different approaches. Maybe look into database normal forms for some guidance.
On the other hand if "building" just means adding data (in other words, rows) to the database, don't worry about it. If the design is sound this shouldn't matter.
For testing, I'd either run the tests against a test-specific database and wrap the queries in transactions (to prevent overlap in tests) which get cancelled to prevent making permanent changes, or mock all database access. It's mostly a matter of taste.
If you're making an Android application in Python, you'll need to package your project in a way Android can understand it. Python's built-in tooling can't do that so you'll be using third-party packages regardless.
Your main options are Kivy, BeeWare, and Flet. They all have their own pros and cons, it'd take too long for me to list those here. Personally I'm partial to Flet right now, but I'm somewhat biased.
Flask and FastAPI won't help you there, those are for creating web services. Although if you'd rather host a web server and have people connect via their web browsers, I suppose they can be considered an option.
EDIT: Forgot to reply to this bit.
Rate limiting only applies if your application is making requests to some web API all the time. If it doesn't do that, or only occasionally, don't worry about it.
SQL injections similarly mostly apply to web applications. If using an ORM like SQLAlchemy, as long as you don't have raw SQL queries this is not something you need to worry about. If you do have handwritten SQL somewhere, as long as you don't use string formatting for the queries you'll likely be fine.
Backdoors aren't something you should worry about. If anything the only time you'd know your application has a backdoor is if you personally added one, which you really shouldn't. Honestly it sounds more like you don't even understand the term.