I'll answer it myself. There will also be a reminder for the future.
Instead of virtual machines, install Windows Subsystem for Linux (WSL) - right-click on the start menu, WindowsPowerShell (administrator), wsl --install, reboot.
Go to the project folder via the WSL console. Or open the path to it in the explorer and on the folder where it finds the main program file (or inside this folder in an empty place), and press Shift+PCM. A new item will be added to the context menu ""Open the Linux shell"" here, click there.
IMPORTANT!!! In the folder name with main.py there should be no spaces. And the main file should be called .main.py (you can change this requirement in step 5)
- Enter the command (to paste the copied text into the console, right-click it ):
sudo apt update
e>
If at the end of her work we see errors like:
W: Failed to fetch httph http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'archive.ubuntu.com'W: Failed to fetto fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'W: Failed to fetch httph http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Temporary failure resolving 'security.ubuntu.com'W: Some index files failed to dolass="">to download. They have been ignored, or old ones used instead.
then we enter the commands one by one
echo ""nameserver 8.8.8.8"" | sudo tee /etc/resolv.conf > /dev/nullsudo apt update
If there are no errors, but the last line says something like
4 packages can be upgraded. Run 'apt list --upgradable'/span> to see them.
then write
sudo apt updesudo apt update
It seems like it's optional., but in my opinion, it's better to upgrade.
- We continue to enter the commands one at a time :
sudo apt install -y git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-configconfig zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-devpip3 install --user --upgrade Cython==0.29.33 virtualenv export PATH=$PATH:~/.local/bin/pip3 install --user --upgrade buildozerbuildozer init
- A settings file will appear in the folder, which can be edited even with notepad or IDLE. In the dependency line, add the imported modules. In my case, instead of
kivy, we need pygame, pygame-menu and typing-extensions. You can also change the title, author, orientation, etc. there. It is described in sufficient detail in the official documentation.
# (list) Application requirements# comma separated e.g. requirements = sqlite3,kivyrequirementsements = python3,pygame,pygame-menu,typing-extensions
In my opinion, this point is the most important, since my application crashed until I added the latest typing-extensions module. It is needed because of the pygame-menu module, but it works on a PC without it, and its addition for android is not documented anywhere. To understand this, I had to find out what Android Studio, logcat, virtual device, decryption of logs, etc. are. The remaining items are more convenient to configure when the application is already running and you can see the difference when they change in different builds. But if you mess up here, you won't be able to launch it.
Closing the file, saving the changes.
- Enter the command to start creating the .apk file:
buildozer android debug
e>
In the examples, it is regularly recommended to add deploy run, but if you did not connect the device in advance, then you do not need to do this. Without these commands, the .apk file will be compiled, which you will drop yourself where you need to. For the first time during the file creation process, you will need to enter y 2 times to agree to the license terms. The .apk file will be in the bin folder, and then you can download it to your phone or virtual device.
Personally, I'm in buildoser.spec bin_dir = /mnt/h/yadisk, where YADISK is a folder that automatically syncs all contents with the cloud. Immediately after the file is created, it ends up in this folder (or overwrites the previous version) and is sent to the cloud. All that remains is to open the cloud on your phone and run the synchronized .apk for installation. The most convenient method without using cables that I could come up with. Youhone supports such synchronization