使用Python 编写安卓APP 可以使用BeeWare.
使用了Pycharm,整个安装过程还是比较顺畅。
安装Python
1)在Python 官网上下载安装了python-3.10.0-amd64
2)安装Pycharm,选择python3.10做interpreter
3) 安装git
4)pip install briefcase
5)打开Pycharm 创建项目后,输入briefcase new,然后根据提示输入信息如APP名称等。
版权我选择了9
What license do you want to use for this project’s code?
Select one of the following:
[1] BSD license
[2] MIT license
[3] Apache Software License
[4] GNU General Public License v2 (GPLv2)
[5] GNU General Public License v2 or later (GPLv2+)
[6] GNU General Public License v3 (GPLv3)
[7] GNU General Public License v3 or later (GPLv3+)
[8] Proprietary
[9] Other
Project License [1]: 9
GUI框架我选择了Toga
Select one of the following:
[1] Toga
[2] PySide2 (does not support iOS/Android deployment)
[3] PySide6 (does not support iOS/Android deployment)
[4] PursuedPyBear (does not support iOS/Android deployment)
[5] None
Generating a new application ‘GTD’
Application ‘GTD’ has been generated. To run your application, type:
运行成功会产生一个与APP同名的目录。
运行应用程序,要输入
cd myApp
briefcase dev
然后出现了这个界面
6 创建Android App
6.1创建Android平台环境
输入命令 briefcase create android
然后问Y/N选择y
6.2编译程序
输入briefcase build android
6.3 运行模拟器
briefcase run android
在目录android\gradle\myApp\app\build\outputs\apk\debug
目录下面产生了APK文件
6.4 打包安卓应用
输入命令briefcase package android
产生app-release.aab文件
在目录C:\Users\angela\PycharmProjects\App\myApp\android\gradle\myApp\app\build\outputs\bundle\release中可以找到
Android App Bundle 是 2018 年推出的Android 发布格式。
修改代码时主要需要用到的文件包括:
1)app.py
2)main.py
3)pyproject.toml