Windows下利用BeeWare开发python安卓应用

步骤:

1、安装 python3.8

      更新pip源: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

      查看pip源: pip config list

2、创建Beeware环境

        mkdir beeware                           
        cd .\beeware\
        py -m venv beeware-venv
        beeware-venv\Scripts\activate.bat  //激活虚拟env

        pip install briefcase

3、编写Beeware应用

1.访问 API:使用jsonplaceholder(https://jsonplaceholder.typicode.com)作为数据源
2.安装第三库,例如:pip install httpx
3.briefcase dev #本地运行
4.briefcase update : 更新app代码
5.briefcase build : 编译app
6.briefcase run : 运行app 
7.启动时提示module not found: 
    1.修改app全局依赖: key:[tool.briefcase.app.appname]
        1.修改pyproject.toml,修改requires,将依赖添加至requires
        2.添加时可以指定版本与版本范围,例如:httpx==0.19.0,httpx>=0.19
        3.指定克隆仓库的路径: 如"git+https://github.com/encode/httpx"
    2.修改指定平台的依赖: key:[tool.briefcase.app.appname.macOS、windows、linux、iOS、web、android]
        1.修改pyproject.toml,修改requires,将依赖添加至requires
8.Python只在移动端:
    1.在桌面平台: 任何pip能安装的都可以被添加到你的需求中
    2.在移动平台: 只能使用纯Python包及包中不能包含二进制模块,numpy、scikit-learn、cryptography等不能在移动平台上使用
9. briefcase update -d #更新依赖
10.briefcase build #编译
11. briefcase run # 运行

4、 更新app代码


①打包之后修改代码使用briefcase dev可使修改生效,若使用briefcase run修改无效。
②使用briefcase update为现存的应用程序包更新代码;
     使用 briefcase build命令重新编译app,
     使用briefcase run 命令运行升级后的app,
     使用 briefcase package 命令重新打包app以便分发。
③若想一步更改代码,更新app,迅速重新运行你的app,使用briefcase run -u 命令。
④如果你修改了app代码并想快速打包,可以使用briefcase package -u命令。
⑤对大多数日常开发,briefcase dev命令更便捷。
 

5、让APP更流畅

1.GUI事件循环: 当app正在处理一个事件,不能重绘也不能处理其他事件
2.异步编程: 使用 async 和 await 关键字实现


5、测试APP

1.briefcase dev -r #自动检查依赖安装情况
2.briefcase dev --test #执行测试
3.test_app.py #编写测试用例
4.briefcase run --test -r #运行时测试
5.briefcase run iOS --test、 briefcase run android --test #指定平台运行测试用例

6、依赖的三方库

   pip install pywebview
   pip install pydum
   pip install pydub
   pip install pygame
   pip  install baidu-aip
   pip install playsound
   pip install xlwt
   pip install xlrd
   pip install win32com
   pip install bs4

briefcase build android -u -r --update-support  --update-resources --test
briefcase build android -u -r --update-support  --update-resources

briefcase run -u

briefcase update android
briefcase build android
briefcase dev android

briefcase update
briefcase build
briefcase dev

参考:

python-23-使用BeeWare开发手机APP-CSDN博客

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值