Convert Python to Android with WINDOWS & LINUX + Fix Common Bugs
Vložit
- čas přidán 24. 07. 2024
- In this tutorial, I will show you how to convert your Python projects into Android applications - USING WINDOWS! 😎
We will Create a Windows Subsystem for Linux (WSL), Learn about Android's Debug Bridge (adb) and use Buildozer to compile our .py files into .apk.
By the way, I'm extra annoying in this video so my apologies in advance! 🤪 I've detected a few crazy cat lady moments while editing... I don't know why I was shouting at the keyboard 😅
ANYHOW... For this project, we will first need to learn about 🥝Kivy or KivyMD🥝, which are Python GUI libraries that are responsible for the interface of the app.
🛑 If you're not yet familiar with Kivy or KivyMD - check out any of my quick tutorials:
⭐ Mobile App with KivyMD ⭐
• Mobile App with KivyMD...
⭐ Expand Mobile App with KivyMD ⭐
• Expand KivyMD GUI App ...
⭐ Simple App with Kivy ⭐
• Simple Python App with...
⭐ EXTRA: Python Classes and OOP ⭐
• Python Classes and Obj...
(will help with understanding the App Class)
*********************************************
⏰ Time Stamps: ⏰
00:00 - intro
00:30 - Install Windows Subsystem for Linux (WSL)
05:14 - Install Buildozer and Dependencies
06:52 - Android Debug Bridge (adb)
09:53 - Developer Options on Android Device
10:38 - buildozer.spec requirements
12:06 - Start Windows adb server
12:44 - Operation not permitted FIX
13:34 - Convert Python to Android
15:45 - Icons not displayed on Android FIX
18:05 - Thanks for watching! see you soon! 😊
*********************************************
Special thank you to Delphi Niki and WinTush
for sharing your code with me on Github! 😁
*********************************************
My Github:
github.com/MariyaSha
Windows Subsystem Docs:
docs.microsoft.com/en-us/wind...
Android Platform Tools:
developer.android.com/studio/...
Buildozer Documentation:
buildozer.readthedocs.io/en/l...
Icons Not Displaying Issue on Github:
github.com/kivymd/KivyMD/issu... - Věda a technologie
I always get the error message: "Unknown command/target android" after the command "buildozer -v android debug". I followed your tutorial step by step so far. I only used a different python-file and some picture which were all in the folder- Do you have an idea what the problem could be?
Good explanations btw. ;)
Hi Tim! 😃
Are you using Windows 7 by any chance?
Sorry, I haven't encountered this error earlier but I've noticed somebody on stack overflow did and they were using Windows 7:
stackoverflow.com/questions/60077141/building-an-android-app-with-kivybuildozer/70162831#70162831
It seems that something is wrong with the Buildozer installation but I couldn't find a proper solution to it online... everyone just replies with "you can't work with Buildozer on Windows" and refers to Google Colab (which never even seemed to work for me).
I don't think it's the problem here, but does your version of Kivy and KivyMD matches mine? you can find out the exact version with "conda list" or "pip list" and make sure you update it in the requirements in your buildozer.spec file. (it's a long shot, it's probably unrelated but it's worth a try)
If everything matches but the error repeats, do you mind loading your code to Github so I can take a closer look?
Thanks! 😊
@@PythonSimplified Thanks a lot! I found a way now. I still don't now what the problem is but here is the short story:
I used to convert my python apps via Colab to APKs for my android phone. For some reason it stopped working and that is why I looked up your video. Your way doesn't work for my setup for some reason (maybe I did something wrong idk). But you gave me that idea to check the version of my kivy application. Now that I have updated my kivy, the old way works again! So thanks again for the quick reply and for your video! A lot! Because I spend 3 days on that problem by now and it didn't cross my mind to check if my kivy version was old (yeah I guess I am dumb lol). Thanks!
@@timmaassen9234 wow!! I can't believe it worked!! I didn't think it was the problem but I'm super happy it helped!!! 😃😃😃
Also happy to hear that the Colab way works for you! Do you mind sharing which tutorial you followed to get it done? It might help other folks who stumble upon this video and have issues with the WSL way 😊
And you're most certainly not dumb!!! It wasn't an obvious issue!!! It's just a matter of troubleshooting! 😉
@@PythonSimplified Unfortunately, I cannot remember the exact tutorial, but I can share the code:
!pip install buildozer
_____
!pip install cython==0.29.19 # might be updated when newer version is released
____
!lsb_release -a
____
!sudo apt-get install -y \
python3-pip \
build-essential \
git \
python3 \
python3-dev \
ffmpeg \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libportmidi-dev \
libswscale-dev \
libavformat-dev \
libavcodec-dev \
zlib1g-dev
____
!sudo apt-get install -y \
libgstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good
____
!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6
____
!sudo apt-get install libffi-dev
____
!buildozer init
____
!buildozer -v android debug
This code will create a bin folder insider Colab containing the APK file. You can dowload it to your computer and from there load it onto your phone. After that you just need an APK installer. Voila!
(Do not forget to make sure that both the kivy and kivymd versions fit to the one from your app!!)
P.S.: I cannot remember where the code is from. I remember that it is from a tutorial from some youtuber. Please comment it if you know it so I can give a link and credit!!!
Your channel is amazing, not just because the content you teaches, but by your crystal clear explanation too.
As always, your pace and the way of explanation of the tutorials, are excellent for beginners like me to follow along. I like all your videos.
Thank you so much for the lovely feedback Kabilan! 😁 Super glad to have you onboard! 😊
CZcams recommended me this video and I don't even know how to make a web page, but the tutorial is so well done that now I wanna learn Python
I am a beginner of Python. I was always attracted by your enthusiasm in your lectures. As recent as today, I failed twice in converting a kv file into apk. Then I realized that I don't need this approach at all. I'll just need Android Studio to write Android apks. So, thanks for your info, although I won't be using it. I am sure I shall need your help in the future. Stay put, take care! Good luck!
Hi! I was looking for some help in PT-BR for this matter and then I found your video. Thank you so much. You can´t believe but I lost several times installing and reinstalling Linux virtual machines in VirtualBox for nothing. And then, you, in less than 20 min helped me to solve my buildozer issues. So thank you!!!! Congrats!
I had no idea about python a few months ago. I just started coding. Thank you very much for your useful content. I loved your explanation. Thanks again, good luck.
I can't thank you enough for this tutorial. I am going nuts trying to find ways on how to be able to create the .apk file and finally use the app in my android phone. You are a lifesaver! Glad I was able to find your channel.
Amazing video and very well explained, I love it!. Thank you so much, I'm wondering how the hell you don't have at least 100k subscribers... Your content is very good.
Increduble! Wow!! Thank you Mariah . It works for me. All your steps were correct from A to Z.
You are amazing. Exact step by step instructions without any "waffling" about.
Followed every step and it worked perfectly. Thank you so much for all these guides, they help a lot!
Yeeey!! Thank you so much, Francisco!! I'm super happy I could help!!! 😀
I remember I spent 3 days on trying to figure out how this conversion works, and when I did figure it out - I couldn't remember the exact steps that led me there so I had to start all over again 😅😅😅 hahahahahah
Thank you so much for your support, I really appreciate it! 😊
My mouth are openned...
How you turnned the Pandora box in a golden cup in the finish rainbow!!!!
Loved this video and also you english continues perfect, clear and good to understood.
Congratulations more on time!!!
Big hug from Brazil!!!
Thank you so much for the incredible comment Luis!
So happy you liked this tutorial, I hope it helps with your conversion! 😁
Just Great.
For so many days trying to convert .py kivy program to apk but no use. After following your tutorial everything is just working smooth as it should. Thanks a lot.
Awesome tutorial! I have been working with Windows kivy apps, but was missing a clear tutorial on how to bundle for Android! Thank you só much!
i hate when the links does not match with what you are showing
I don't really work with python, only for small things, but your explanations are so good that i understand everything and i've been practicing with your videos, thanks Mariya!
I'm so thankful to see this video. Hope it works once I followed your steps. Thank you. By the way, I already subscribed in your channel. I expect more Python videos in the future.
Woow! Thanks for this detailed tutorial!! You make it look soo easy :D
Thank you Lopo!! 😁 it is indeed very easy when you follow my tutorial!
Can't say it was anywhere near easy to figure out without it though 😅 There are many Stack Overflow and Github debugging threads scattered around the internet... so it's like finding a fish in the ocean 🤪
Mounting C: and matching the Windows adb server were quite a nightmare... but not anymore! 😉
Thank you so much. This was awesome and actually working in contrast to many other tutorials.
Earned a sub today. Glad I stumbled upon you. Thank you so much and keep going!
Hey Maria!. Thanks a lot for this video. It worked and I finally converted my kivy and kivymd file into an apk. 😄💕
Hi there! I converted a .py file to an .apk file using Google Colab. Once the file was created, I installed it on my Android device. However, when I opened the app, it immediately crashed and closed. I have no clue what's going on, and I've tried fixing it in many ways, but nothing seems to work. Can you suggest any solutions? Thanks!
Does it work if we have multiple folders in the main.py directory? Do I have to change any line in the spec file or just keep it like in the video?
Hi Mariya, thanks for the video. I have a question: how did you get the adb version 1.0.39? I could not find it.
Hey there, I'm quite new to kivy and exporting apk. I was wondering if the three adb files could have been copy/pasted in the B2D files to replace them? Else why not? Thanks a lot! :)
Wow: This is Incredibly Helpful, Thanks ~
You Are My Favorite Computer Instructor On The "Tube" ~
Keep it Coming ~
Thank you so much, always a pleasure reading your comments! 😁😁😁
you are a great teacher explaning everything clearly. glad ı found your channel. subscribed.
Hello Mariya, I am writing to thank you for your contribution, you have a very understandable way of explaining. But when executing the program it gave me an error, and I detected that the problem is in this instruction: from kivymd.uix.toolbar import MDToolbar, my question is: how did you manage to use the MDToolbar?
where can I get my older version of adb like you had on the B2D folder? I don't have that from my python project.
Did you manage to figure out how to get adb for your project, I have the same question at the moment? Thanks!
Might be a stupid question, but is it possible to install these application at the external SD-card, if these is formated as "internal storage" or must it be installed next to the operating system? But besides: Great work! I was searching a long time for these topic...
Thank you for this video. This was very useful for me I don't know about other's❤️
Hello, i just go through the video.
I installed an android debug Bridge version 1.0.41 and as the adb version of the file is 1.0.39 it does not match.
What should i do in this case ?Thank u?
18:12 The sound of Victory.
Thank you for your wonderful tutorial.
hahahaha YES! I struggled so much with debugging everything that a Hallelujah praise was a must! 😁
You're absolutely welcome and I hope it helps everybody with their conversion! 😊
Hi! What program did you use to mirror your phones srcreen, and what did you use for the UI?
thanks you for your tutorial but i don't know how to get the adb 1.0.39 for windows! can you help me please?!
Hi, Your Tutorial really helped me. But there is single error i.e the app installed on my phone go toloading mode and quickly stops working. The app closes itself
I've never seen someone spell Mariya like that! How cool. Also sweet tutorial!
Thank you Nick! It's the Ukrainians who decided to spell it that way on my passport... I'm actually very lucky they didn't go for Marija 🤣🤣🤣
at 11:48 how do you check your kivymd version? I can check my kivy version from pip freeze, but can't see my kivymd version under pip freeze
The tutorial dosent work for me even when Mariya tried to debug the buildozer -v android debug by the sudo mount command thing i followed the exact same process but that didnt work!
Greetings, i have a Xiaomi and run through your video with the downloaded B2D-App, but the app wont start as used to... How can i fix it or wich smartphone would be better?
Hi. I try to make that on Linux (VirtualBox) I need to install a Kivy before i run buildozer?
Guys am In love with her teaching python. Thank you alot
is it required to have the adb in my project folder?
If I run the "buildozer -v android debug" in the project folder in /mnt/c/users/... I get an error (not the permission error, before the red text there is nothing specifically mentioned). Do you know what the problem could be?
If I copy the project to my home directory on the ubuntu, I am able to build the apk. When running the App on the phone though it crashes after the loading screen.
Dear Mariya, let me congratulate you for this video. Your explanations were easy to understand and implement. Your detailed and clear explanations were unique to me
and helped me to create an android app in my cell phone and tablet. The question I have for you is how to incorporate an icon, other than the one of the kivy app, in my phone or tablet.
Thanks a lot, Alkis
hey i might be late on this video but at 12:59 when i executed the cmd "buildozer -v aandroid debug" it didnt give me an error and its still going on debugging something and its been more than 30mins now . I just wanna know that if its normal or not
Good video. As a student of python and other languages, this was helpful
At 6:07 I am constantly getting the error of "python error could not find a version that satisfies the requirement buildozer" even though I used the latest adb files from the Internet. Any suggestions?
You have good knowledge.
And
Very very nice
your teaching style and your voice .thanks ❤️❤️❤️
Your tutorials are the best. Thank you for sharing. I am trying to figure out my app that includes sqlite3, a form and a list for a CRM System. It works fine on my laptop. But It keeps crashing after showing the first form screen. I am using linux mint 20.1, python 3.8, kivy 2.1.0 and kivymd 1.1.1.. Any advice will be appreciated. Thank you.
Hi Mariya, I really need your help here. I used libraries such as openpyxl and random in my kivy app. It works fine when running in windows. I followed your video on converting to apk but after building the apps I opened it in my mobile and it shows the kivy loading.. and crash. I did add openpyxl in the library and its version as instructed. Then i exclude openpyxl and random from my app and it works fine. So, how can I used those libraries?. Does buildozer not support openpyxl, random or any other library than kivy.
Hi Mariya. Great video! Could you please let me know which "phone mirror app " do you use at 10:30 ?
Hey mariya I have a question. Do we need the adb server if we are using our own python file? Sorry if this is s dumb question😅
I love you so much i have been waiting for this video for months
I love you so very much
excellent video, well explained and everything works perfectly, keep it up.
Many thanks for this video... You're amazing!!! Thanks for sharing 😍
Hello I have a project where I use audio files they were wav extension but my apk crash stating it could Not find the files location. I try including it in the bulldozer spec file and still had the same problem
Can you please tell me what should I do... I am getting error- build failed: requested api target 27 is not available, install it with sdk android tool ... while debugging
Hi Mariya, any chance you can do this with Termux running on the same Android device (compile). So, with Pydroid 3 for python, Termux for Linux, all running on an Android Tablet?
please help , when i type buildozr init the terminal say command not found !!
If your app is crashed after the loading screen, you can try following: in buildozer spec file after the string "source.include_exts =" type all extentions of files of your project, including database file, font, picture... everything.
I have Kivy/KivyMD code with many folders like assets and fonts and .kiv files, how to reach all and convert to android ?
Hi, I have successfully created the APK and I tried opening it on my phone but it is not opening. It is showing loading with the kivy logo and closing. Please help me.
I love your way using your hands for teaching purpose ❤
It helps me to stay in rhythm! hahahaha 🤣
plus, I grew up in the Middle East so I can't really speak without hand gestures... I'm waving them all over the place even in person 🤪
@@PythonSimplified My wife does that ... despite my incessent nagging.
Thank you for the completed explanation. This is what I needed
You're absolutely welcome Benjamin!
Let me know how it turned out on your end! 😊
@@PythonSimplified abd not installing
I'm getting an HTTPError: HTTP Error 503: Service Unavailable. The downloading worked the first time and even got through a couple of yes' options but then it gave me that HTTP error. After the error, now every time I run the buildozer -v android debug i can't even get to the first yes or no option. I'm using library public Wi Fi.
Hi!!! Thanks to you .....my apk is ready but do you know how to create option of in app purchase?
please help my problem is when i do sudo apt python3-pip it says "Package 'python3-pip' has no installation candidate"
Thank you for this video Mariya, it's very interesting!!!! ¡Saludos!
Hi, I did as told and created the APK and installed it. But when I open it the app tries loading and crashes. Can you please guide me on how to rectify this?
Its working! I am very happy about that! I can`t wait to try it with application of my own 🙂
That's awesome! Have fun! 😁😁😁
@@PythonSimplified Thank you very much Mariya! ❤ I have a question. What if our project contain a .kv file. Do we need to change something else?
Hi, could you help me to convert my kivy app, it doesn't open my app on my phone, I've tried everything in builderdozer and nothing.
HOw can i get the error log of why my app crashes.Please please help,I am looking for it but didn't know how to do it.There seem to be no tutorial on it except for use linux
hi, i am getting this error:
sdkmanager path "/root/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager" does not exist, sdkmanager is notinstalled
how can i fixed this?
when i did the "sudo mount -t drvfs C: /mnt/c -o metadata" for the warning, it gave me:
/mnt/c: C: already mounted or mount point busy.
ERROR: UtilCreateProcessAndWait:501: /bin/mount failed with status 0x2000 error, does anybody know how to fix it?
I get the following error message when running the buildozer -v android debug command: "WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available". Could you help me out?
Thanks. The ADB bridge part confused me. Ultimately, I think what you're saying is to upload to a phone, we need a folder with a main.py program, and 3 files from SDK (adb.exe and two .dll). However, the adb.exe from the SDK download probably won't match our Linux version--- so we should just copy these three files from your github. Is that correct?
thx your comment was very helpful :)
Hi python simplified I am getting error
Buildozer failed to execute the last command # the error might be hidden in the log file above this error #please
Read the full log , and search for it before raising an issue with bulldozer itself
Hello my dear and beautiful programmer friend, this topic is very interesting. I speak Spanish and I will see a way to learn what you explain to us. Thanks
After entering "sudo mount -t... metadata" I get the same error, I would appreciate your help, thanks a lot.
i went to the link if windows Subsystem docs but i did not see the steps and the things you were talking about .
thanks for a video .. if i have .py script that when run its open terminal so i put inputs in it , how to convert it to apk ?
Thanks for the great tutorial. One problem though, when I click the X on the top right of the window, the app locks up. How do we end the app?
i did everything but my app gets closed when i click to open it. It does not opens
Thanks for your video! I was able to get it to work overcoming a few glitches on the way. Would it be possible to give some references to know how you figured out your dependencies? For instance, how did you know to add pillow as a dependency? Did you just run it and get error messages?
+1
I know this comment is old, but for anyone else wondering. The python code for the app imported pillow, if the python code imports a library, it's a dependency.
Thank you for doing this. I did come up with a snag, which does list on their website but I can't see to get it fixed. Do you know how to fix the Aidl not found, please install it error?
Best easy explanation i seen at all.
Awesome video, thank you very much :)
Thank you so much for your tutorial. I followed this to a T, but every time i try to open my app on my android device, it crashes. I've tried to run a logcat on Ubuntu but it cannot find my device, even though powershell sees it, do you have any suggestions?
hi...I love your explanations, enjoyable, understandable, learnable....My wishes!!
hello everyone i want to implement the feature where app is logged in till the user does not logout but when i rerun the app after closing then it requires login how to implement this feature please help
Can you show how to install JDK on linux, when its says Unable to locate package openjdk-17-jdk
I wanna use tenserflow inceptionV3 in python and then make it a mobile app..is it possible?????
Hi Mariya, I had build a Car Game using Python library "Pygame" for my high school project. I was able to make its setup file and install on any computer and play. But I wanted to run the game on my android phone. Tried using this tutorial but not helpful can you suggest some way of making an apk from Pygame lib in python.
You know now?
If I added a specific code (Text to voice - pyttsx3) and as a result, the app fails to run, how can I debug it?
Thanks for the energetic tutorial as always. The line was left commented out while setting config to point to github fork. Was that intentional?
Hi Mariya! Could it be possible to convert an app made with PyQt5 to Android? Thanks!
I am enjoyed the lecture, however, i keep getting this error : c compiler cannot create executables buildozer, please what should i do, i am just new to this whole kivy conversion episode
Hi I stuck on downloading ndk after the download is done and reach 100% it doesn't move forward for the rest I think it could not unzip ndk and even no error show up it just stuck please help me out with that
My APK is not working it's open and close automatically. It's an weather app need solution please 😓