My rant about python’s kivy……

Kuria Joseph
4 min readJan 3, 2019

--

Photo by Yura Fresh on Unsplash

I have been programming for quite a while using python and i really love the language. I love learning how to use different libraries and frameworks everyday and so i had this new project that i was going to work on and it entailed development of a cross-platform smartphone application that would work on android and ios devices(who uses windows phones anyways???). I was super pumped since i had not made any production level smartphone application. I looked around to see my options and the python libraries that could help me achieve this were kivy and pybee. Kivy draws its own UI while pybee uses the respective platform’s native components.

Pybee is still new and some features are not working yet and as far as i know its not ready for production use but its a promising project. My only option was kivy. I had seen some beautiful desktop apps made in kivy on youtube so i thought this would be easy.

Photo by Tyler Lastovich on Unsplash

Since i did not want to develop the UI from scratch i used kivy material design components developed and maintained by HeaTTheatR. The library is awesome and he responds very quickly to issues and questions on github and google groups. I learned kivy language within a few hours and i was able to finish the UI design and some part of the logic within a few hours because thats how it should be.

The next step was compiling the application to respective platforms. Everything was working well so far so i thought compilation would not take that long. I went through kivy’s documentation and found out that you can only compile the app using linux or unix . No major fuss about it since am familiar with linux . So i booted up my virtual machine and i installed the latest Ubuntu OS and everything was working well and up-to-date. So i prepared the buildozer spec file as per instructions i found online and installed the cython version recommended and all the required libraries. I was compiling the application to android apk since to compile an ios app you need to be on a macos (apple and their rules!!). So buildozer is supposed to install the sdk for you and all the android build tools required, i ran the command build android deployand sat back and waited for it to finish. It was going to take some time since the sdk was being downloaded and its a 1GB+ file and my internet isn’t fast enough.

After downloading and installing , compilation began. But wait! Error detected ‘file requires permissions’ but buildozer says in the docs dont run the commands as sudo. Ok lets run as sudo , everything worked well then i was hit with another error message something to do with cython . I searched for similar issues on github and some say downgrade to cython==0.25 …other fixes say upgrade to the latest version. I tried downgrading and ooh man! I got the error once more. I upgraded to the different versions but the issue persisted. Whats going on!!

Photo by Ryan Franco on Unsplash

I went through a sample application written using kivy material and tried to build the cloned repo but the same issue persisted. So i found another fix that was suggested in kivy github issues. By now i was getting frustrated! The fix suggested that i should clear the cache of buildozer and start a fresh . Ok cool! This meant deleting the sdk(1GB+) and redownloading. I did that and after around an hour another error from hell appeared. Argggh!!!

I wasted a full day trying to make it work but it actually did not work!

Then after searching on stackoverflow and the documentation i saw they provide a kivyVM image that comes preinstalled with the required tools so that errors don’t occur. Finally, this should work, i thought. When i ran the buildozer deploy command i was hit with an error . By this time i was about to give up. The error stated i should sudo update. Of course i did that then guess what happened? Error! By this time i was so pissed that i started laughing at myself. Luckily i found a fix and i was back to buildozer deploy command. This time i decided to download the android ndk instead of sdk. After updating everything finally it worked it compiled to an apk. I transferred the apk file to my smartphone to test out my app. By now i was feeling relieved! But wait! The app crashes and does not even start. I gave up after 4 days of trying to make it work.

Photo by Arny Mogensen on Unsplash

I decided to look at other cross-platform tools such as dart and nativescript. I decided to go with nativescript and i could not be more happier. The ease of development and deployment makes it my number 1 choice when i want to develop production level apps. I am not bashing kivy ,but i would advice you to stay away from it if you are looking to build something serious easily.

That’s my two cent’s!!

--

--