π±πΠΠ°ΠΊ ΡΠ΄Π΅Π»Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄ Android Π½Π° Python: ΠΏΠΎΡΠ°Π³ΠΎΠ²ΠΎΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ
Π§ΡΠΎΠ±Ρ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄ Android Π½Π° Python, Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΠ΅ΠΉΠΌΠ²ΠΎΡΠΊ Kivy. ΠΠΎΡ ΠΏΡΠΈΠΌΠ΅Ρ ΠΏΡΠΎΡΡΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ:
import kivy
kivy.require('1.11.1')
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
return Button(text='ΠΡΠΈΠ²Π΅Ρ, ΠΌΠΈΡ!')
if __name__ == "__main__":
MyApp().run()
Π ΡΡΠΎΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠ΅ ΠΌΡ ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠ»Π°ΡΡ MyApp, ΠΊΠΎΡΠΎΡΡΠΉ Π½Π°ΡΠ»Π΅Π΄ΡΠ΅ΡΡΡ ΠΎΡ ΠΊΠ»Π°ΡΡΠ° App ΠΈΠ· Kivy. ΠΠ΅ΡΠΎΠ΄ build Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅Ρ ΠΊΠ½ΠΎΠΏΠΊΡ Ρ ΡΠ΅ΠΊΡΡΠΎΠΌ "ΠΡΠΈΠ²Π΅Ρ, ΠΌΠΈΡ!". ΠΠ°ΡΠ΅ΠΌ ΠΌΡ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Ρ ΠΏΠΎΠΌΠΎΡΡΡ MyApp().run().
ΠΠ΅ΡΠ°Π»ΡΠ½ΡΠΉ ΠΎΡΠ²Π΅Ρ
ΠΠ°ΠΊ ΡΠ΄Π΅Π»Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄ Π°Π½Π΄ΡΠΎΠΈΠ΄ Π½Π° python
ΠΡΠ΅ Π±ΠΎΠ»ΡΡΠ΅ Π»ΡΠ΄Π΅ΠΉ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΡΡΡΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΎΠΉ ΠΌΠΎΠ±ΠΈΠ»ΡΠ½ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π΄Π»Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ Android Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΡΠ·ΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Python. Python ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠ΄ΠΎΠ±Π½ΡΠΉ ΠΈ ΠΏΡΠΎΡΡΠΎΠΉ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ, Π° ΡΠ°ΠΊΠΆΠ΅ ΡΠΈΡΠΎΠΊΠΈΠΉ ΡΠΏΠ΅ΠΊΡΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊ ΠΈ ΡΡΠ΅ΠΉΠΌΠ²ΠΎΡΠΊΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π΄Π΅Π»Π°ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ ΠΏΠΎΠ΄ Android Π±ΠΎΠ»Π΅Π΅ Π΄ΠΎΡΡΡΠΏΠ½ΠΎΠΉ ΠΈ ΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΠΎΠΉ. Π ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΠΌΡ ΡΠ°ΡΡΠΌΠΎΡΡΠΈΠΌ, ΠΊΠ°ΠΊ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄ Android, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ Python.
1. Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ²
ΠΠ΅ΡΠ²ΡΠΌ ΡΠ°Π³ΠΎΠΌ Π΄Π»Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΏΠΎΠ΄ Android Π½Π° Python ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ². ΠΠ°ΠΌ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅:
- Python: Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π²Π΅ΡΡΠΈΡ Python Ρ ΠΎΡΠΈΡΠΈΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠ°ΠΉΡΠ° https://www.python.org.
- Kivy: Kivy - ΡΡΠΎ ΠΎΡΠΊΡΡΡΠ°Ρ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠ° Python, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠ°Π·ΡΠ°Π±Π°ΡΡΠ²Π°ΡΡ ΠΌΠ½ΠΎΠ³ΠΎΠΏΠ»Π°ΡΡΠΎΡΠΌΠ΅Π½Π½ΡΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π²ΠΊΠ»ΡΡΠ°Ρ Android. Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ Kivy Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
pip install kivy
2. Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
Π’Π΅ΠΏΠ΅ΡΡ, ΠΊΠΎΠ³Π΄Π° Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Ρ, ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΡΠ°Π³ΠΎΠΌ ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. Π‘ΠΎΠ·Π΄Π°ΠΉΡΠ΅ Π½ΠΎΠ²ΡΠΉ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ .py ΠΈ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΊΠΎΠ΄:
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='ΠΡΠΈΠ²Π΅Ρ, ΠΌΠΈΡ!')
if __name__ == '__main__':
MyApp().run()
Π ΡΡΠΎΠΌ ΠΊΠΎΠ΄Π΅ ΠΌΡ ΠΈΠΌΠΏΠΎΡΡΠΈΡΡΠ΅ΠΌ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅ ΠΌΠΎΠ΄ΡΠ»ΠΈ Kivy ΠΈ ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠ»Π°ΡΡ MyApp, ΠΊΠΎΡΠΎΡΡΠΉ Π½Π°ΡΠ»Π΅Π΄ΡΠ΅ΡΡΡ ΠΎΡ ΠΊΠ»Π°ΡΡΠ° App. ΠΠ½ΡΡΡΠΈ ΠΊΠ»Π°ΡΡΠ° MyApp ΠΌΡ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅ΠΌ ΠΌΠ΅ΡΠΎΠ΄ build, ΠΊΠΎΡΠΎΡΡΠΉ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅Ρ Π²ΠΈΠ΄ΠΆΠ΅Ρ Label Ρ ΡΠ΅ΠΊΡΡΠΎΠΌ "ΠΡΠΈΠ²Π΅Ρ, ΠΌΠΈΡ!". Π ΡΠ°ΠΌΠΎΠΌ Π½ΠΈΠΆΠ½Π΅ΠΌ Π±Π»ΠΎΠΊΠ΅ ΠΊΠΎΠ΄Π° ΠΌΡ ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ ΠΊΠ»Π°ΡΡΠ° MyApp ΠΈ Π²ΡΠ·ΡΠ²Π°Π΅ΠΌ Π΅Π³ΠΎ ΠΌΠ΅ΡΠΎΠ΄ run Π΄Π»Ρ Π·Π°ΠΏΡΡΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ.
3. Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ°
ΠΠ»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΎΠ³ΠΎ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ° Π² ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΈ ΠΏΠΎΠ΄ Android Π½Π° Python ΠΌΡ Π±ΡΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΠ°ΠΉΠ» KV. KV - ΡΡΠΎ ΡΠ·ΡΠΊ ΡΠ°Π·ΠΌΠ΅ΡΠΊΠΈ Kivy, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ Π²Π½Π΅ΡΠ½ΠΈΠΉ Π²ΠΈΠ΄ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. Π‘ΠΎΠ·Π΄Π°ΠΉΡΠ΅ Π½ΠΎΠ²ΡΠΉ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ .kv ΠΈ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΊΠΎΠ΄:
kivy:
BoxLayout:
orientation: "vertical"
Label:
text: "ΠΡΠΈΠ²Π΅Ρ, ΠΌΠΈΡ!"
font_size: 30
Button:
text: "ΠΠ°ΠΆΠΌΠΈ ΠΌΠ΅Π½Ρ!"
4. ΠΠ°ΠΏΡΡΠΊ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
Π’Π΅ΠΏΠ΅ΡΡ, ΠΊΠΎΠ³Π΄Π° Ρ Π½Π°Ρ Π΅ΡΡΡ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΉ ΠΊΠΎΠ΄ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈ ΡΠ°ΠΉΠ» KV Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ°, ΠΌΡ Π³ΠΎΡΠΎΠ²Ρ Π·Π°ΠΏΡΡΡΠΈΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅. ΠΠ΅ΡΠ½ΠΈΡΠ΅ΡΡ Π² ΡΠ°ΠΉΠ» .py ΠΈ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΠ΅ Π΅Π³ΠΎ ΠΊΠΎΠ΄ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class MyApp(App):
def build(self):
return Builder.load_file('my.kv')
if __name__ == '__main__':
MyApp().run()
Π ΡΡΠΎΠΌ ΠΊΠΎΠ΄Π΅ ΠΌΡ Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΈΠΌΠΏΠΎΡΡ ΠΌΠΎΠ΄ΡΠ»Ρ Builder ΠΈΠ· Kivy ΠΈ ΠΈΠ·ΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΌΠ΅ΡΠΎΠ΄ build, ΡΡΠΎΠ±Ρ ΠΎΠ½ Π·Π°Π³ΡΡΠΆΠ°Π» ΡΠ°ΠΉΠ» KV Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΌΠ΅ΡΠΎΠ΄Π° load_file. Π’Π΅ΠΏΠ΅ΡΡ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π·Π°ΠΏΡΡΡΠΈΡΡ Π½Π°ΡΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, ΠΈ Π²Ρ ΡΠ²ΠΈΠ΄ΠΈΡΠ΅ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ Ρ ΠΌΠ΅ΡΠΊΠΎΠΉ "ΠΡΠΈΠ²Π΅Ρ, ΠΌΠΈΡ!" ΠΈ ΠΊΠ½ΠΎΠΏΠΊΠΎΠΉ "ΠΠ°ΠΆΠΌΠΈ ΠΌΠ΅Π½Ρ!".
5. Π£ΠΏΠ°ΠΊΠΎΠ²ΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π΄Π»Ρ Android
Π’Π΅ΠΏΠ΅ΡΡ, ΠΊΠΎΠ³Π΄Π° Π½Π°ΡΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ ΠΈ ΠΈΠΌΠ΅Π΅Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΈΠΉ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ, ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ ΡΠΏΠ°ΠΊΠΎΠ²Π°ΡΡ Π΅Π³ΠΎ Π΄Π»Ρ Android. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΌΡ Π±ΡΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½Ρ KivyBuildozer, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠΎΠ±ΠΈΡΠ°ΡΡ ΠΈ ΡΠΏΠ°ΠΊΠΎΠ²ΡΠ²Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Kivy Π΄Π»Ρ ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΠΏΠ»Π°ΡΡΠΎΡΠΌ, Π²ΠΊΠ»ΡΡΠ°Ρ Android.
Π‘Π»Π΅Π΄ΡΠΉΡΠ΅ ΡΡΠΈΠΌ ΡΠ°Π³Π°ΠΌ, ΡΡΠΎΠ±Ρ ΡΠΏΠ°ΠΊΠΎΠ²Π°ΡΡ Π²Π°ΡΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅:
- Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ Buildozer Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
pip install buildozer
- Π‘ΠΎΠ·Π΄Π°ΠΉΡΠ΅ ΡΠ°ΠΉΠ» Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ buildozer.spec Π² ΠΊΠΎΡΠ½Π΅Π²ΠΎΠΉ ΠΏΠ°ΠΏΠΊΠ΅ Π²Π°ΡΠ΅Π³ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ° ΠΈ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΊΠΎΠ΄:
[app]
# (str) Title of your application
title = ΠΡΠΈΠ²Π΅ΡΠΠΈΡApp
# (str) Package name
package.name = hellomobileapp
# (str) Package domain (needed for android/ios packaging)
package.domain = org.test
# (str) Source code where the main.py live
source.dir = .
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas
# (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png
# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec
# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = tests, bin
# (str) Application versioning (method 1)
version = 0.1
version.requirements = ==0.1
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy
# (str) python-for-android branch to use, defaults to master
#p4a.branch = develop
# (str) python-for-android revision to use (ignored if remote is set)
#p4a.revision = master
# (str) How to build the application, current options are apk (default) or sdist
#p4a.build_mode = apk
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
#arch = armeabi-v7a
# (int) Android API to use
#android.api = 27
# (int) Minimum API required
#android.minapi = 21
# (int) Android SDK version to use
#android.sdk = 20
# (str) Android NDK version to use
#android.ndk = r19c
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
#android.ndk_api = 21
# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True
# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =
# (str) Android SDK directory (if empty, it will be automatically downloaded.)
#android.sdk_path =
# (str) build.prop should be recreate (tweak recipe for that, if False you should have your build.prop tweaked in your system)
#android.remove_buildprop = True
# (bool) allows to use packages which are only available on the host building the android project
#android.allow_backends_apis = False
# (str) The name of the OUYA console
#android.console_otg_device =
# (str) Python2 branch to use, defaults to the latest stable 2.x branch
#py2.branch = stable
# (str) Python3 branch to use, defaults to the latest stable 3.x branch
#py3.branch = stable
# (str) A comma separated list of bootstraps to build for the application
#bootstrap = sdl2
# (int) Port override for the default bootstrap
#android.bootstrap_port = 5046
# (int) Minimum memory size (in MB) required to build sdl2/pygame bootstrap
#use_pgs4a = False
# (int) Target Android architecture to compile your app against, this does not restrict deployment or require API level limitations
#archs = armeabi-v7a
# (str) add java object files
#android.add_objects = %(source.dir)s/android/src/org/test/helloworld/obj
# (str) Gradle dependencies to append
#android.gradle_dependencies =
# (list) Permissions
#android.permissions = INTERNET
# (str) mobile-sdk to use for building (android)
#sdk = 20
# (str) Android logcat filter expression to use
#logcat_filter = *:S python:D
# (str) Android additionnal libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so
# (str) Android additionnal libraries to copy into libs/x86
#android.add_libs_x86 = libs/android_x86/*.so
# (bool) Indicate if the screen should stay on
#android.wakelock = False
# (bool) Indicate if the screen orientation should be kept
# (the default layout only allow portrait orientations)
#android.allow_orientation_change = False
# (str) Application needs a cursor (mouse cursor for instance)
#android.presplash.cursor = True
# (int) Target DPI for cursor to work.
#android.presplash.cursor_dpi = 64
# (str) Presplash of the application
#android.presplash.filename = %(source.dir)s/data/logo/kivy-icon-64.png
# (str) Icon of the application
# Icon filename for application
# Default is android/android/Icon.png
#android.icon.filename = %(source.dir)s/data/logo/kivy-icon-32.png
# (str) Supported orientation (one of landscape, sensorLandscape, etc)
# android.orientation = landscape
# (list) List of application features (separated by commas)
# android.features = android.hardware.usb.host
# (str) Permissions for android
# android.permissions =
# (str) Launch mode to use for the activity (singleTop, singleTask, etc)
# android.launch_mode = standard
# (bool) If you need to insert variables
# android.template_ext_whitelist =
# (str) Path to a custom blacklist file
#android.blacklist =
# (bool) If you want to disable autocapturing of any keyboard
# android.allow_capture_keys = False
# (bool) If the application should be fullscreen without a statusbar
# fullscreen = 1
# (bool) Turn on the --virtualenv option on Android, default is False
# If jnius is required this must be set to True
#android.virtualenv = False
# (str) Verbose level (0-2)
# It will display in the standard output what commandlines are used and the output of those commands
#android.verbose = False
# (bool) If debug is False, the app will not run
debug = False
# (str) Path to a directory containing external requirements
#android.requirements_source_dir = %(source.dir)s/requirements
# (str) Patches to the build
#android.build_patches =
# (str) Path to a custom -android.mk file use this version instead of the default one
#android.custom_mk =
# (str) Path to a custom AndroidManifest.tmpl.xml file, must be relative to the main.py file
#android.manifest_src =
# (str) Path to a custom blacklist file
#android.predex.blacklist =
# (str) Path to a custom whitelist file
#p4a.whitelist =
# (str) Path to a custom obb files dir (default is .)
#android.add_obb =
# (str) Bootstraps to remove
#p4a.remove_bootstraps =
# (str) Whether to run sdl2 bootstrap
#run_sd2_bootstrap = False
# (str) Title of the application
#title = ΠΡΠΈΠΌΠ΅Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
# (str) Package name
#package.name = ΠΡΠΈΠΌΠ΅ΡΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py
# (str) Application icon
# Icon filename for application
# Default is %(source.dir)s/icon.png
#icon.filename = %(source.dir)s/data/logo/kivy-icon-32.png
# (str) Presplash background color (for new android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
#android.presplash_color = #FFFFFF
# (str) Presplash background image to use
#android.presplash.filename = %(source.dir)s/data/images/presplash.png
# (str) Presplash background image to use (simple version)
#android.presplash.filename = presplash.png
# (str) Gradle dependencies to add
# after.main = 'compile "org.robovm:robopods-google-mobile-ads-ios:3.14.0"'
# (str) Android logcat filters to use
# Some users want to get "only" the Kivy log entries via logcat because
# they use a Kivy GUI.
# USAGE: (list of str) ['-S', '*:S', 'python:D', 'python:E', ...]
#android.logcat_filters = *:S python:D python:E
# (str) Android key.store
# Alias for key.store.filename
#android.keyalias =
# (str) Android key.store.password
# Password for the key store
# android.key.store.password = mypass
# (str) Android key.alias
# Alias for the key
# android.key.alias = myalias
# (str) Android key.alias.password
# Password for the key
# android.key.alias.password = mypass
- ΠΠ΅ΡΠ΅ΠΉΠ΄ΠΈΡΠ΅ Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΡ ΡΡΡΠΎΠΊΡ ΠΈ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π΄Π»Ρ ΡΠ±ΠΎΡΠΊΠΈ ΠΈ ΡΠΏΠ°ΠΊΠΎΠ²ΠΊΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ:
buildozer android debug
ΠΠΎΡΠ»Π΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΡΡΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π²Ρ ΠΏΠΎΠ»ΡΡΠΈΡΠ΅ ΡΠ°ΠΉΠ» APK, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΠΎΠΆΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Π½Π° ΡΡΡΡΠΎΠΉΡΡΠ²Π΅ Ρ Android.
ΠΠ°ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
Π ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΠΌΡ ΡΠ°ΡΡΠΌΠΎΡΡΠ΅Π»ΠΈ, ΠΊΠ°ΠΊ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄ Android Π½Π° ΡΠ·ΡΠΊΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Python. ΠΡ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΠ»ΠΈ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ, Π½Π°ΠΏΠΈΡΠ°Π»ΠΈ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΉ ΠΊΠΎΠ΄ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, ΡΠΎΠ·Π΄Π°Π»ΠΈ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΠ°ΠΉΠ»Π° KV ΠΈ ΡΠΏΠ°ΠΊΠΎΠ²Π°Π»ΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π΄Π»Ρ Android Ρ ΠΏΠΎΠΌΠΎΡΡΡ Buildozer. Π’Π΅ΠΏΠ΅ΡΡ Ρ Π²Π°Ρ Π΅ΡΡΡ Π²ΡΠ΅ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅ Π·Π½Π°Π½ΠΈΡ, ΡΡΠΎΠ±Ρ Π½Π°ΡΠ°ΡΡ ΡΠΎΠ·Π΄Π°Π²Π°ΡΡ ΡΠ²