I wanna know if i can use buildozer for non-kivy python scripts. Is it possible to build apk files from ordinary python scripts other than kivy scripts?
I would say that it probably isn't possible. However, you should ask in the kivy support group. You need to join it to post. Some people there really seem to know their kivy, and in my experience, I haven't had to wait too long for answers.
EDIT:
If you look in the buildozer.spec file of your project, you will see the following lines are included by default:
# (list) Application requirements
requirements = kivy
While this makes it seem like kivy may be a requirement for all projects with buildozer, you could try commenting out the requirements or something and see what happens when you try to compile code without kivy.
Or since that is a bit of a backwards way to do it, as you would have to have already created your buildozer.spec file. Perhaps you could just try using buildozer on a project without kivy and see what happens.
Related
I heard information that Android can make apps using kivy or pythonForAndroid.
But I don't know if I can make Android sdk using the above.
Even if there was information, I couldn't check because the version was very different because it was written a long time ago.
What I am most curious about is that I want to make a lib used in Android app and put Python Code in it.
I'd like you to help me, even if it's a small word.
Thank you for reading it
https://github.com/yausername/youtubedl-android/blob/master/BUILD_PYTHON.mdhttps://github.com/yausername/youtubedl-android/blob/master/BUILD_PYTHON.md
I tried the link above, but it failed because I blocked it in git.
I tried pythonForAndroid, and I failed...
All I want is to be able to use pythonCode and pythonlib as I said above.
I am new to Android studio, but I decided to write my first app using kivy and then with help of buildozer create .apk file out of it.
App works on my ubuntu when running python main.py.
After some struggle (following the video https://www.youtube.com/watch?v=yr7n0C2tspI&ab_channel=ShawCode) it worked and command
buildozer -v android debug worked creating .apk file.
I uploaded it to google drive and then installed on my phone, but it did not start (black screen for a couple of seconds and then it exits).
I decided it would be a good idea to try to debug it using Android-studio and launched it but as I am new to it I am not quite sure how to use it.
I tried to open directory when the project is located, but it acts, as it could not run it.
Anyone has idea what I am doing wrong, or how to fix this situation?
[EDIT] I managed to run LogCat and extract logs (warnings and errors) from my app.
Here they are:
2021-05-25 12:52:59.581 19114-19130/org.test.misia W/libEGL: [ANDROID_RECORDABLE] format: 1
2021-05-25 12:53:02.495 19114-19143/org.test.misia E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
2021-05-25 12:53:02.499 19114-19143/org.test.misia W/libEGL: [ANDROID_RECORDABLE] format: 1
Unfortunately they don't say much. Anyone able to translate them and see what causes it?
well, you are doing one crucial thing wrong: you are trying to import project made in some IDE (PyCharm?) in Android Studio, which does NOT support such projects. "mobile" project made in one IDE rarely works in any other IDE, due to different project structure and sometimes even language. you've picked Kivy and Python, you have to go with it and it's tools, Android Studio is for native apps, not some ports/forks. powodzenia
After some debugging and running another android emulator
we were able to conduct that the reason for crashing was that not all packages were included in buildozer.spec. The full list is:
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy,kivymd,mapview,requests,urllib3,chardet,idna
Now it starts correctly.
Too long for a comment, but it might be helpful.
For cross platform frameworks, I've seen examples where the code produces an Android Studio project and the final step is to use Android Studio to build the project. That's why some developers suggest looking at building a native app first when you start developing apps: so that you understand how the native tools work.
Going by the Kivy documentation, it looks like Kivy produces an apk file using buildozer (as you've done), but not an Android Studio project. From here, to debug it, it looks like you're going to have to use log files and logcat.
In your app code, you'll need to write to STDOUT or STDERR (i.e. you'll need to add some log statements).
In Android Studio, you'll need to attach logcat to a running instance of your code. There are two options for this. You can either use a cable to attach your actual phone to the computer with Android Studio running on it and then connect LogCat to that. Alternatively, you can use Android Studio to start an emulator (you'll need to select a suitable emulator - there are lots of options), then install your .apk file on that emulator (i.e. just click and drag the .apk file on to the emulator once it's open).
LogCat should then be able to see the output from your apk file (although you'll probably have to filter LogCat's output because some apps can be quite "chatty" on LogCat).
Unfortunately, debugging it might be difficult - with Android Studio, you need to select the version of Android that you want to target to produce a suitable .apk for an actual device. I can't see anything in your post that indicates that you've actually made that choice, so I've no idea what level of Android you're targeting. You might get some debug info out of LogCat, but it might just be something about your app failing to launch.
Recently I followed a Kivy tutorial, and I made a calculator. I then wanted to use it on my phone, so I used Kivy Launcher. The problem is, it only uses Python 2, which for some reason, didn't have support for Unicode characters. Also, a lot of the syntax was very different, so I had to change a lot of the code. Just so I could test it out on my phone.
Is there a Python 3 version for the Kivy Launcher? I've seen things like https://github.com/kivy/python-for-android/issues/1638 but how do you build it? I've ran setup.py and I got a .egg file. What do I do with it? Do I have to make an APK using python-for-android or buildozer?
Also, a lot of the syntax was very different
I think it would be more accurate to say that a small amount of the syntax was somewhat different.
The problem is, it only uses Python 2, which for some reason, didn't have support for Unicode characters
Python 2 did have support for unicode characters, although the subtleties around how they're handled are one of the real differences between Python 2 and 3.
Is there a Python 3 version for the Kivy Launcher?
It's possible to build a Python 3 version of the old launcher, or the new one that you've found. However, in both cases if you can build the launcher you could also just build a standalone apk, so you probably may as well follow the instructions to build your own app with buildozer.
I've ran setup.py and I got a .egg file. What do I do with it? Do I have to make an APK using python-for-android or buildozer?
It sounds like you've built a desktop package for the launcher, if you want to build an apk you must indeed use those projects.
I've figured out some ways to achieve what I wanted.
Get Pydroid 3. Install kivy using Pip and just run it.
Use buildozer to build the Kivy Launcher. Then I can test out some code without building it all.
Use VirtualBox to build. Download a version of Ubuntu/Lubuntu and build the APK.
Recently I've been working on a project that involves a phone taking a picture, processing it in some way, and returning the output on the screen. In order to do this, I would have to use openCV, but when I try to "import cv2" in the Kivy code using the launcher, the app crashes immediately after I run it. I realize now that the reason this happens is because the Kivy launcher by itself can only do basic functions like print and such and there must be extra steps needed to use external libraries. I tried to use Buildozer to create a package for android, but soon found out that it only would work for linux computers, while I use Windows.
Essentially, my question is: Is there any way to include an external library in Kivy without using buildozer? And if there is, could you please describe it or post a link to a webpage that contains instructions(as I am fairly new to programming and am somewhat of a noob)
Thanks!
You can try python-for-android.
But the easiest way - install virtual box to your PC, download kivy/buildozer for VirtualBox( it calles Virtual Machine (for Android/buildozer)) here below: https://kivy.org/#download and then just connect downloaded vmdk-disk to VirtualBox, and then use this. Everything is prepared, you don't need to install kivy or buildozer.
You will spend about 30-40 minutes.
This is my first attempt in hosting one of my Python projects and after reading multiple tutorials, I am confused on which steps are necessary (i.e. writing it into a python package, freezing it as an .exe, etc)? A lot of the tutorials seem to be overkill for what I feel should be an easy task.
Currently, I have two .py files (one for the gui and one for the back-end) and few miscellaneous data files. The program works for Python 2 and 3.
The end goal would be to have a file or package that another person would be able to download from my website that has a desktop icon executable that prompts the gui. The package will need to be able to install a list of requirements (I can do this through a requirements.txt file?).
Would anyone know what the "bare bones" structure should be? (i.e. would I need to write it as a package or would freezing it with a req instllation pre-pended to the gui file work?)
Thanks!