аватар question@mail.ru · 01.01.1970 03:00

How to create a .APK file using Buildozer in Windows?

When you try to create a file .apk through Buildozer I faced a problem that if you do it in windows , then Target Android is visible, this is clear In the terminal Buildozer Help . If you create a virtual machine with ubuntu , then this problem is not there, but so far I would not want to switch to it, early yet. Probably a problem due to the fact that you need to install the python-and-endroid module, but it is not available for Windows, if I understood correctly.

This is my first attempt to use Buildozer, Ubuntu and virtual machines , so that the brains are already boiling, perhaps I don’t understand. Some kind of nuance.

Does anyone know how to add separately target for Android ? Or install the python-for-Android module, if it's about it? Or can you tell me a guide where the work is shown step by step Buildozer specifically for Windows? I didn’t find such a guide, and for the official documentation for some reason it doesn’t go out to achieve the result.

as a last resort - please tell me how else can I create .APK Python file from windows ? Game for pygame , if it is important.

The first screen is the Pycharm terminal in Windows, the second in Ubuntu

аватар answer@mail.ru · 01.01.1970 03:00

I'll answer it myself. There will also be a reminder for the future.

  1. Instead of virtual machines, install Windows Subsystem for Linux (WSL) - right-click on the start menu, WindowsPowerShell (administrator), wsl --install, reboot.

  2. 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)

  1. 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.

  1. 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
  1. 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.

  1. 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

Latest

Similar