Build Android Apps with Flet in Python (APKs)

NeuralNine · Intermediate ·⚡ Algorithms & Data Structures ·2y ago

Key Takeaways

Builds Android apps using Flet in Python

Full Transcript

what is going on guys welcome back in this video today we're going to learn how to build Android applications with python using flat and how to actually turn them into an APK file so a file that can be run on Android natively so let us get right into [Music] it all right so recently I made a video on this channel where I showed you guys how you can easily build goey applications using flat and Python and those were platform independent and device independent so you can just write python code and you can run the application on the web you can run it locally you can run it on Android on iOS and so on but those were actually not Standalone packages or applications so there were not APK files or executables for Windows those were just running on the web and then you could connect with your phone now with the most recent update we have the possibility to actually build APK files to actually build executables for Windows and so on uh and for this of course what we need to do first of all is we need to uh upgrade flat so if you have flat installed already you have to say pip or pip three install flat-- upgrade otherwise just pip install flat if it's the first time you're installing it uh now in this video today I don't want to focus too much on flat itself if you want to know what flat is and how to build an application in general how to add buttons and stuff like this watch the previous video today we're going to focus on actually building an application and getting it on our phone on our Android phone uh as an APK file so make sure you upgrade the package to get the latest functionality and then what we're going to do is we're going to navigate to our working directory in my case this is the current directory and in here now I'm going to just create a simple uh flat project so flet create my application um and then what we can do just as a reminder we have this main py file this is our flat application it's now basically just a simple hello world application you can of course add buttons and uh functionality and stuff like that this uh but remember what we can do is we can run this as an application here we can go to the command line we can say flat actually first of all I need to go into my application then I can say flat run or flat run-- web to run it in the browser um I can also say flat run-- Android which basically runs it in the browser and lets me connect to it um through my uh through my Android application and so on so we also have Android um but this is of course not the same as building an APK file and getting it onto my phone uh that's of course different so this is what we're going to do today now again I'm not going to focus on the code so this is going to be our application I'm not going to change anything about it we're going to go with a simple application the process is the same now what we need to do first here is we need to install flutter and we need to install at least on Linux a couple of other things as well now you probably have to install the same things on Mac and on Windows but probably in different ways since I'm running here uh or since I'm working here on Linux I'm going to to show the Linux process but the idea is the same install flutter and install uh the tools that I'm using here so first of all on Linux on Debian based distributions you can use snap to install flutter so pseudo app install or pseudo snap install uh flutter let me just zoom in a little bit maybe let me go to uh let me clear this and let me go to this directory so I have more space so what we're going to do here is we're going to say pseudo snap install flutter if you are an enemy of snaps you can also install flutter in a different way the important thing is that you have flutter on your system then you also want to install pseudo app install android-sdk and also the SDK manager those are basically uh the Android development kit and the manager for this development kit that's the basic uh tool here and what we need to do now is we need to uh accept certain licenses and we need to also run flat in a certain way that downloads and accepts the licenses that are necessary to download and accept so what you can do in general uh once you have the SDK manager installed this you can run SDK manager D- licenses and this is going to show you if you have to accept any licenses then you can just accept them I personally had the issue that I had to work around this so what I had to do was I needed the pseudo privileges so I needed the root privileges here to actually be able to download the proper licenses and accept them but also I had to still maintain the neural 9 user environment here so not the root user environment so what I had to do is actually pseudo- e and then SDK manager D- licenses uh and then I also installed a certain piece of software or a certain I mean software a package uh for the SDK uh manually I I basically said pseudo- SDK manager install and then it was I'm just going to put it here in in case you need this ndk 23.1 and then 777 9620 probably in your case it's going to be a different one if you're watching this in the future the reason I had to install this was because when I ran the flat pack uh or the flat build command Flat buil APK command it told me that it was not able to install and accept the license for this here so I had to install this manually I had to accept the licenses and then what I did is I went into my working directory again so prep deer go back go to current uh we go to my application and here now what I do is I run the command flat built APK now the problem with flatb built APK is in my case it didn't have the permissions to do anything so what I had to do actually is I had to do pseudo um pseudo- e flatb build APK but then flat is no longer recognized so I actually had to figure out where flet is on my system so which FL was the command I figured out it's here and what I basically ran as the final command that actually works is pseudo- e then the full path so home neural 9. local bin flet built APK and this now basically after you provide the root password is going to generate your APK file from python um or from from the python script it's going to use flutter behind the scenes and it's going to basically give you an APK file this APK file you're going to then take and put on Google Drive or use a USB cable or something to get it onto your phone and then you can uh allow your phone to install it by default your phone is going to be very suspicious it's going to tell you that this is not a secure application you just have to enable the settings that you allow unknown apps to be installed then you click on it to say install anyway and once it's installed you can basically just use the application so once this process here is finished we're going to continue uh on our phone here all right so now the process is finished you can see success everything went fine and what we have now is we have a directory called build inside of that we have a directory called APK and inside of that we have app- rel. APK this is the file you want to get onto your phone however you want to do that in my case I already downloaded it here from Google Drive so I uploaded it to Google Drive I downloaded it to uh my phone from Google Drive and then basically I just navigate to the directory it's in I click on the APK file I say I want to open it with the package installer uh it asks me if I want to install the application I click on install then it tells me unsave app blocked I have to go to more details and click on install anyway uh and once this is done I can open the application and on my phone you cannot really see that very well but you can see here it says hello flet this is basically the application that I just just wrote here in Python the same thing that I run or the same thing I see when I run uh the application on my computer just that for some reason it opens now on my second screen okay doesn't matter but this is how you build APK files with flat you can do the same thing with Windows you just have to say flat build windows I didn't do that yet so maybe you have to install some components there uh but this is now a new feature of flet so just install the necessary packages and then flat build APK so that's it for today's video I hope you enjoyed it and hope you learned something if so let me know by hitting a like button and leaving a comment in the comment section down below and of course don't forget to subscribe to this Channel and hit the notification Bell to not miss a single future video for free other than that thank you much for watching see you in the next video and bye

Original Description

Today we learn how to build Android apps (APKs) using Flet in Python. ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾ 📚 Programming Books & Merch 📚 🐍 The Python Bible Book: https://www.neuralnine.com/books/ 💻 The Algorithm Bible Book: https://www.neuralnine.com/books/ 👕 Programming Merch: https://www.neuralnine.com/shop 💼 Services 💼 💻 Freelancing & Tutoring: https://www.neuralnine.com/services 🌐 Social Media & Contact 🌐 📱 Website: https://www.neuralnine.com/ 📷 Instagram: https://www.instagram.com/neuralnine 🐦 Twitter: https://twitter.com/neuralnine 🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/ 📁 GitHub: https://github.com/NeuralNine 🎙 Discord: https://discord.gg/JU4xr8U3dm
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from NeuralNine · NeuralNine · 0 of 60

← Previous Next →
1 Visualizing Stock Data With Candlestick Charts in Python
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
2 Python Beginner Tutorial #1 - Installation and First Program
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
3 Python Beginner Tutorial #2 - Variables and Data Types
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
4 Python Beginner Tutorial #3 - Operators and User Input
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
5 Python Beginner Tutorial #4 - If Statements and Conditions
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
6 Python Beginner Tutorial #5 - Loops
Python Beginner Tutorial #5 - Loops
NeuralNine
7 Python Beginner Tutorial #6 - Sequences and Collections
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
8 Python Beginner Tutorial #7 - Functions
Python Beginner Tutorial #7 - Functions
NeuralNine
9 Python Beginner Tutorial #8 - Exception Handling
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
10 Python Beginner Tutorial #9 - File Operations
Python Beginner Tutorial #9 - File Operations
NeuralNine
11 Python Beginner Tutorial #10 - String Functions
Python Beginner Tutorial #10 - String Functions
NeuralNine
12 Python Intermediate Tutorial #1 - Classes and Objects
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
13 Python Intermediate Tutorial #2 - Inheritance
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
14 Python Intermediate Tutorial #3 - Multithreading
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
15 Python Intermediate Tutorial #4 - Synchronizing Threads
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
16 Python Intermediate Tutorial #5 - Events and Daemon Threads
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
17 Python Intermediate Tutorial #6 - Queues
Python Intermediate Tutorial #6 - Queues
NeuralNine
18 Python Intermediate Tutorial #7 - Sockets and Network Programming
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
19 Python Intermediate Tutorial #8 - Database Programming
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
20 Python Intermediate Tutorial #9 - Recursion
Python Intermediate Tutorial #9 - Recursion
NeuralNine
21 Python Intermediate Tutorial #10 - XML Processing
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
22 Python Intermediate Tutorial #11 - Logging
Python Intermediate Tutorial #11 - Logging
NeuralNine
23 Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
24 Python Data Science Tutorial #2 - NumPy Arrays
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
25 Python Data Science Tutorial #3 - Numpy Functions
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
26 Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
27 Python Data Science Tutorial #5 - Subplots and Multiple Windows
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
28 Python Data Science Tutorial #6 - Matplotlib Styling
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
29 Python Data Science Tutorial #7 - Bar Charts with Matplotlib
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
30 Python Data Science Tutorial #8 - Pie Charts with Matplotlib
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
31 Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
32 Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
33 Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
34 Python Data Science Tutorial #12 - Pandas Series
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
35 Python Data Science Tutorial #13 - Pandas Data Frames
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
36 Python Data Science Tutorial #14 - Pandas Statistics
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
37 Python Data Science Tutorial #15 - Pandas Sorting and Functions
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
38 Python Data Science Tutorial #16 - Pandas Merging Data Frames
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
39 Python Data Science Tutorial #17 - Pandas Queries
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
40 Python Machine Learning Tutorial #1 - What is Machine Learning?
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
41 Python Machine Learning Tutorial #2 - Linear Regression
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
42 Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
43 Python Machine Learning #4 - Support Vector Machines
Python Machine Learning #4 - Support Vector Machines
NeuralNine
44 Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
45 Python Machine Learning Tutorial #6 - K-Means Clustering
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
46 Python Machine Learning Tutorial #7 - Neural Networks
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
47 Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
48 Generating Poetic Texts with Recurrent Neural Networks in Python
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
49 Stock Portfolio Visualization with Matplotlib in Python
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
50 Analyzing Coronavirus with Python (COVID-19)
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
51 Making Text Images Readable Again with Python and OpenCV
Making Text Images Readable Again with Python and OpenCV
NeuralNine
52 Neural Networks Simply Explained (Theory)
Neural Networks Simply Explained (Theory)
NeuralNine
53 Motion Filtering with OpenCV in Python
Motion Filtering with OpenCV in Python
NeuralNine
54 Top 5 Programming Languages To Learn in 2020
Top 5 Programming Languages To Learn in 2020
NeuralNine
55 Simple TCP Chat Room in Python
Simple TCP Chat Room in Python
NeuralNine
56 Image Classification with Neural Networks in Python
Image Classification with Neural Networks in Python
NeuralNine
57 Edge Detection with OpenCV in Python
Edge Detection with OpenCV in Python
NeuralNine
58 S&P 500 Web Scraping with Python
S&P 500 Web Scraping with Python
NeuralNine
59 Simple Sentiment Text Analysis in Python
Simple Sentiment Text Analysis in Python
NeuralNine
60 Introduction - Algorithms & Data Structures #1
Introduction - Algorithms & Data Structures #1
NeuralNine

Related Reads

Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →