Build Android Apps with Flet in Python (APKs)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
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
Info
Channel: NeuralNine
Views: 28,224
Rating: undefined out of 5
Keywords: python, flet, flutter, python flet, python flutter, python flet app, android, apk, android app, python android app, python android apk, python flet android, python flet android apk, flet android, flet android apk, flet android app, python flet android app
Id: Hj09tFCdjSw
Channel Id: undefined
Length: 8min 59sec (539 seconds)
Published: Fri Jan 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.