You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Although you do not need this for a base PySide6 application, I still recommend you to
106
+
> read through the following part, because it contains very important things for your Android App.
107
+
108
+
Buildozer is the tool which generates the .apk file using P4A (Python for Android) as backend.
109
+
The buildozer.spec file is a configuration file which is generated on Buildozer's first run.
110
+
It's used to configure the behaviour of your application. For example whether your App should
111
+
run in portrait or landscape mode and other things. Here's a list of the most important options:
112
+
113
+
-`requirements`: The list of all python packages used in your app See [Buildozer.spec](#the-buildozerspec-file)
114
+
-`icon.filename`: The Icon of your App as a .png or .jpg. Please have a look at Google's [Adaptive Icons](https://developer.android.com/develop/ui/views/launch/icon_design_adaptive?hl=de)
115
+
-`title`: Your App name
116
+
-`version`: The version of your application e.g, 1.1
117
+
-`android.permissions:` All permissions your App needs. Have a look at [Android Permissions](https://developer.android.com/reference/android/Manifest.permission.html)
118
+
-`package.name`: The name of your package, which is the output of buildozer
119
+
-`package.domain`: The unique identifier of your app inside the Android app system
120
+
-`orientation`: The orientation of your app: `portrait` ->: `||` or `landscape` ->: `===`
121
+
122
+
#### Special Note on `charset_normalizer` and `requests`:
123
+
If your project uses the 'requests' library or any other library dependent on 'charset_normalizer', ensure to specify
124
+
the version `charset-normalizer==2.1.1` in your requirements, otherwise there will be an architecture
125
+
mismatch.
126
+
127
+
128
+
### PySide6 modification
129
+
Unfortunately the `pyside6-android-deploy` script starts the build proces immediately, without giving
130
+
you the option to manually review the buildozer.spec file, which is the reason why we need to do
131
+
a little modification, but don't worry it's easy:
132
+
133
+
1) Go into your virtual environment to the PySide6 folder (e.g: venv/lib/python3.11/site-packages/PySide6/scripts/)
134
+
2) Edit the `android_deploy.py` file.
135
+
3) Search for the line: `logging.info("[DEPLOY] Running buildozer deployment")`
136
+
4) Above this line write this: `input("Modify your buildozer.spec now")`
137
+
10
138
11
-
# Building the Qt for Python Wheels
139
+
When you start building the apk with `pyside6-android-deploy` the build process will stop at some point,
140
+
and then you can make adjustments to the `buildozer.spec` file. After you are done, just press enter
141
+
the build process, and it will go on using your own options in the requirements.
142
+
143
+
# The final build process
12
144
> [!IMPORTANT]
13
-
> You can use the pre-compiled Wheels in the Repository's release. If they don't work, you need to compile them
14
-
> You will however still need to set up your Android SDK / NDK, so that it works for buildozer.
145
+
> Make sure your script is named `main.py`
146
+
147
+
Go into your source directory and type the following:
148
+
149
+
`pyside6-android-deploy --wheel-pyside=<your .whl file for the architecture> --wheel-shiboken=<your .whl file for your architecture> --name=main --ndk-path ~/.pyside6_android_deploy/android-ndk/android-ndk-r26b --sdk-path ~/.pyside6_android_deploy/android-sdk/
150
+
151
+
#### Explanation:
152
+
- --wheel-pyside= Here comes your PySide6 wheel which you've downloaded or compiled
153
+
- --wheel-shiboken= Here comes your Shiboken wheel which you've downloaded or compiled
154
+
- --name= The name of your application
155
+
- --ndk-path= The path to your Android NDK (See [Setup](#setup))
156
+
- --sdk-path= The path to your Android SDK (See [Setup](#setup))
157
+
158
+
159
+
The script will start configuring buildozer and buildozer will start the build process.
160
+
At the end you will have a .apk file for the specified Android architecture.
161
+
162
+
### Installation (Best practices)
163
+
164
+
I generally recommend you to use ADB / Fastboot to install, and debug your Android application.
165
+
Once you understood how it works, it makes your life a lot easier...
166
+
167
+
1. Go into your system information and tap a few times on your build number
168
+
2. Go (or search) into the developer settings
169
+
3. Enable USB-Debugging (Or Debugging over W-Lan, but this is a little bit advanced)
170
+
4. Install the android-tools on your system:
171
+
- On Arch Linux: `sudo pacman -S android-tools`
172
+
- On Ubuntu: `sudo apt install android-tools-adb android-tools-fastboot`
173
+
- On Windows: `Imagine using Windows lol`
174
+
175
+
5. Type: `adb devices`
176
+
6. On your device there should be a popup asking for your permission. Click on confirm.
177
+
7. Type: `adb devices` once again and confirm, that you see your device there.
@@ -112,101 +348,3 @@ Now, execute this command for all 4 Android architectures.
112
348
Your Wheels should be in the `dist` folder at the end.
113
349
114
350
If you get any errors, try to use the `--clean-cache all` argument first.
115
-
116
-
# Building the Android APK
117
-
118
-
## PySide6 modification (Important)
119
-
> [!IMPORTANT]
120
-
> If your project depends on external libraries other than PySide6, you need to do the following steps:
121
-
122
-
1) Go into your virtual environment to the PySide6 folder (e.g: venv/lib/python3.11/site-packages/PySide6/scripts/)
123
-
2) Edit the `android_deploy.py` file.
124
-
3) Search for the line: `logging.info("[DEPLOY] Running buildozer deployment")`
125
-
4) Above this line write this: `input("Modify your buildozer.spec now")`
126
-
127
-
Done :)
128
-
129
-
Explanation:
130
-
131
-
Later, when buildozer builds your .apk the `buildozer.spec` file will be created. It defines a lot of things, and also
132
-
which external libraries are used. Unfortunately the pyside6-android-deploy script doesn't let you edit this file, which
133
-
is the reason why we need to make an input statement, so that you can write your external libraries in their, before it
134
-
gets processed. (Sidenote: it took me 6 months to figure this out :skull:)
135
-
136
-
# Building the APK
137
-
The wheels are in pyside-setup/dist/ (Or use the downloaded ones from releases)
138
-
```pyside6-android-deploy --wheel-pyside=<your .whl file for the architecture> --wheel-shiboken=<your .whl file for your architecture> --name=main --ndk-path ~/.pyside6_android_deploy/android-ndk/android-ndk-r26b --sdk-path ~/.pyside6_android_deploy/android-sdk/```
139
-
140
-
> [!NOTE]
141
-
> If you've changed your NDK version, you of course need to adapt the path to your NDK version.
142
-
143
-
### Other Stuff (Important)
144
-
145
-
#### pysidedeploy.spec
146
-
147
-
The `pysidedeploy.spec` file is used to define your Application name, the architecture and some other things.
148
-
The `pysidedeploy.spec` file is created when you build your first .apk. You can use this file by doing:
149
-
150
-
`pyside6-android-deploy -c pysidedeploy.spec` This makes the process easier.
151
-
152
-
#### External Libraries
153
-
If your App needs external libraries like requests or colorama, you need to list them in the
154
-
`requirements` line (in the buildozer.spec). Just separate them with a comma.
155
-
You can specify exact version numbers like with pip and also install from git using `git+....`
156
-
157
-
#### App Icon
158
-
If you want to use your own App Icon you can do:
159
-
<br>
160
-
`icon.filename = <path_to_your_app_icon_png>`
161
-
162
-
# Debugging / Error finding
163
-
164
-
I HIGHLY recommend to download the Android studio and run your App from the Android Studio.
165
-
Just connect your Phone or Tablet to your PC, enable USB Debugging and start your App from the Android
166
-
Studio, because this will allow you to easily profile and debug your apk. You will see all Python tracebacks, and it makes
167
-
it a lot easier to debug.
168
-
169
-
## Special Note on 'charset_normalizer'
170
-
If your project uses the 'requests' library or any other library dependent on 'charset_normalizer', ensure to specify the version `charset-normalizer==2.1.1` in your requirements.
171
-
172
-
# Storage Permissions
173
-
Kivy and Pyjnius don't work. We can't access the Java API on Android and therefore can't request Permissions at runtime.
174
-
You need to use a lower Android API to ue the legacy storage paths in /storage/emulated/0/...
175
-
176
-
177
-
# Errors:
178
-
- RuntimeError: "You are including a lot of QML files from a local venv..."
179
-
180
-
This error is related to your virtual environment. Make sure your virtual environment
181
-
is NOT inside your projects' folder. It doesn't matter where it is, but must not be in your projects'
182
-
folder. For example, if you have your main.py in a folder named my_project, then your
183
-
virtual environment can't be in this folder!
184
-
185
-
Create a new virtual environment in a different location and delete your old one with
186
-
`rm -rf venv .venv` (or whatever you've called it)
187
-
188
-
This is more an issue from Qt and will hopefully be fixed in a later Qt release, so that
189
-
you don't need to do this anymore. I know it's confusing.
190
-
191
-
- c compiler can not create executables
192
-
Don't worry, this issue most of the time comes because you are using a too high API level. Just go into the path, where it
193
-
says the C compiler wouldn't be able to create executables and then look inside this directory. You'll find files ending like
194
-
`androidclang33-` (or something like that). The highest number which is there is the highest number you can select.
195
-
196
-
- blah blash blah is for x86_64 architecture not aarch64
197
-
<br>Solution: Search online if the pip package has a verified aarch64 version. If it doesn't prepare for some months of work
198
-
building the receipes lmao
199
-
200
-
> [!IMPORTANT]
201
-
> I AGAIN want to remind you of using the Java version 17! Java 11 is supported by Gradle and even recommended, but not
202
-
> supported by Qt, and version 21 is supported by Qt, but not by the currently used Gradle version. This may change in the
203
-
> future and I will update it accordingly.
204
-
205
-
# Contributions / Issues
206
-
If you see Issues in this guide, or you have something to improve it, feel free to open PRs and Issues. I'll
207
-
respond to them and try to help you as much as possible. (Only for Arch Linux).
208
-
209
-
Maybe someone of you can make an alternative readme for other distros. Would be nice :)
210
-
211
-
# Support
212
-
I appreciate every star on this repo, as it shows me that my work is useful for people, and it keeps me motivated :)
0 commit comments