Pyqtdeploy Android PyQtForAndroid 编译记录【更新中
2015-09-08 19:52
429 查看
PyqtDeploy 部署 Android 记录
第一次接触PyQt还两年前,写了许多应用后对于PyQt的简单直接很喜欢,用PyQt写Android听起来就好好玩,之前就有过PyQt4 For Android的测试,不过需要另外安装巨大的 Android 运行库 ministro,着实是不方便不好看,ministro还是建立在Qt4时代,现在Qt5已经完全支持Android了,很好前天开始寻找PyQtDeploy的资料开始编译,国内基本没有什么资料,直接看文档,花了两天时间虽然编译出了Apk,但是没有运行成功,这部分的资料实在是太少了,第一次出现的EGL渲染错误,试验平台Android5.0 EGL3.0,第二次 Android4.4.2 EGL2.0,仍然没有运行成功,希望后期可以解决
PyQtDeploy
对各个库的静态编译配置将PyQt代码生成对应C++代码,对应的QtAndroid工程
相关参考资料
https://pypi.python.org/pypi/pyqtdeploy/http://pyqt.sourceforge.net/Docs/pyqtdeploy/tutorial.html
https://plashless.wordpress.com/2014/09/16/deploying-pyqt-python-qt-apps-cross-platform-using-pyqtdeploy/
https://plashless.wordpress.com/2014/08/19/using-pyqtdeploy0-5-on-linux-to-cross-compile-a-pyqt-app-for-android/
相关下载点
http://www.qt.io/download-open-source/https://riverbankcomputing.com/software/sip/download
https://riverbankcomputing.com/software/pyqt/download5
https://www.python.org/downloads/source/
http://ant.apache.org/bindownload.cgi
编译环境
全部 32位1. Windows10 Pro
2. Ubuntu14.04.02
3. Qt5.5.0 Python3.4.0 PyQt-gpl-5.5 sip-4.16.9 pyqtdeploy 1.1
4. Android-sdk23 Android-ndk-r10e Apache-ant-1.9.4
核心步骤
静态编译Qt5.5.0 Python3.4.0 PyQt-gpl-5.5 sip-4.16.9 的 Android 平台版本http://pyqt.sourceforge.net/Docs/pyqtdeploy/static_builds.html
编译 Qt工程
使用 QtCreator
具体操作
1.准备工作
更新好你Android设备平台对应的AndroidSDK,要安装好Armv7Image环境变量 SYSROOT,主要为编译好的库存放设置,
所有路径别加空格
下载好除Qt外的Python3.4.0 PyQt-gpl-5.5 PyQt-gpl-5.5.1-snapshot-03781fa3b27e sip-4.16.9 pyqtdeploy 1.1源码 放置在SYSROOT/src下
安装好Qt,使用带安卓ArmV7支持的Qt
qt-opensource-windows-x86-android-5.5.0.exe,
qt-opensource-linux-x86-android-5.5.0.run
Linux 安装好 GCC Make Java Sip Pip3 等命令工具
本机编译使用各路径
Windows
C:\Python34 D:\android\android-ndk\android-ndk-r10e D:\android\android-sdk D:\android\apache-ant-1.9.4-bin D:\Java\jdk1.7.0_45 G:\Qt\Qt5.5.0 G:\Qt\src\PyQt-gpl-5.5 G:\Qt\src\Python-3.4.0 G:\Qt\src\sip-4.16.9
Linux
/home/harry159821/android/android-ndk-r10e /home/harry159821/android/android-sdk-linux /home/harry159821/android/apache-ant-1.9.4 /home/harry159821/Qt5.5.0 /home/harry159821/SYSROOT /home/harry159821/SYSROOT/src/PyQt-gpl-5.5 /home/harry159821/SYSROOT/src/PyQt-gpl-5.5.1-snapshot-03781fa3b27e /home/harry159821/SYSROOT/src/Python-3.4.0 /home/harry159821/SYSROOT/src/sip-4.16.9
2.pip 安装 PyQtdeploy
Windowspip install pyqtdeploy
Linux
sudo pip3 install pyqtdeploy
3.静态编译 Python3.4.0
WindowsCMD运行 pyqtdeploycli --package python --target android-32 configure SET ANDROID_NDK_ROOT=D:\android\android-ndk\android-ndk-r10e G:\Qt\Qt5.5.0\5.5\android_armv7\bin\qmake.exe SYSROOT=C:\Python34\Lib\site-packages\pyqtdeploy D:\android\android-ndk\android-ndk-r10e\prebuilt\windows\bin\make.exe D:\android\android-ndk\android-ndk-r10e\prebuilt\windows\bin\make.exe install G:\Qt\src\Python-3.4.0\libpython3.4.a
Linux
pyqtdeploycli --package python --target android-32 configure export ANDROID_NDK_ROOT=/home/harry159821/android/android-ndk-r10e /home/harry159821/Qt5.5.0/5.5/android_armv7/bin/qmake SYSROOT=/home/harry159821/SYSROOT make sudo make install
4.静态编译 sip
Windowspyqtdeploycli --package sip --target android-32 configure python configure.py --static --sysroot=C:\Python34\Lib\site-packages\pyqtdeploy --no-tools --use-qmake --configuration=sip-android.cfg SET ANDROID_NDK_ROOT=D:\android\android-ndk\android-ndk-r10e G:\Qt\Qt5.5.0\5.5\android_armv7\bin\qmake.exe D:\android\android-ndk\android-ndk-r10e\prebuilt\windows\bin\make.exe D:\android\android-ndk\android-ndk-r10e\prebuilt\windows\bin\make.exe install
Linux
pyqtdeploycli --package sip --target android-32 configure python3 configure.py --static --sysroot=/home/harry159821/SYSROOT --no-tools --use-qmake --configuration=sip-android.cfg --prefix=$HOME/local export ANDROID_NDK_ROOT=/home/harry159821/android/android-ndk-r10e export C_INCLUDE_PATH=/usr/include/python3.4 sudo cp /usr/include/python3.4m/pyconfig.h /usr/include/python3.4/arm-linux-gnueabi/python3.4m/pyconfig.h /home/harry159821/Qt5.5.0/5.5/android_armv7/bin/qmake make sudo make install
Linux需要把sip安装到你的系统,另外解压一份Sip源码
./configure make sudo make install
5.静态编译 PyQt5
PyQt-gpl-5.5 存在QSSL Bug,使用快照版本https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt-gpl-5.5.1-snapshot-03781fa3b27e.tar.gz
Windows
pyqtdeploycli --package pyqt5 --target android-32 configure python configure.py --static --sysroot=C:\Python34\Lib\site-packages\pyqtdeploy --no-tools --no-qsci-api --no-designer-plugin --no-qml-plugin --configuration=pyqt5-android.cfg D:\android\android-ndk\android-ndk-r10e\prebuilt\windows\bin\make.exe D:\android\android-ndk\android-ndk-r10e\prebuilt\windows\bin\make.exe install
Linux
pyqtdeploycli --package pyqt5 --target android-32 configure python3 configure.py --static --verbose --sysroot=/home/harry159821/SYSROOT --no-tools --no-qsci-api --no-designer-plugin --no-qml-plugin --configuration=pyqt5-android.cfg --qmake=/home/harry159821/Qt5.5.0/5.5/android_armv7/bin/qmake make sudo make install
6.PyQtDeploy生成Qt工程
1.创建工程文件夹,创建pyqt代码这里写代码片
2.pyqtdeploy 配置
pyqtdeploy android.pdy
逐步设置好路径后Build
3.QtCreator 打开 build/android.pro
4.编译
编译过程中的问题
io.h not found
C:\Python34\include/pyconfig.h:68:16: fatal error: io.h: No such file or directory编辑Android.pro
INCLUDEPATH += G:\Qt\src\Python-3.4.0\Include INCLUDEPATH += D:\android\android-ndk\android-ndk-r10e\platforms\android-19\arch-arm\usr\include\
error: errno undeclared
编辑 _math.c mathmodule.c#include <D:\android\android-ndk\android-ndk-r10e\platforms\android-19\arch-mips\usr\include\errno.h>
error: SYS_getdents64 undeclared
编辑 G:\Qt\src\Python-3.4.0\Modules_posixsubprocess.c+#if defined(__ANDROID__) +/* Android doesn't expose syscalls. Let's add the definition manually. */ +# include <sys/linux-syscalls.h> +# define SYS_getdents64 __NR_getdents64 +#endif
参照 http://bugs.python.org/file33551/Python-3.4.0tip-expose-SYS_getdents64-on-android.patch
目前错误进度
http://python.6.x6.nabble.com/pyqtdeploy-SIGSEGV-td5091066.html寻找到的有关链接
http://python.6.x6.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=371140
http://bugs.python.org/issue23496
http://bugs.python.org/review/23496/#ps14460
https://code.google.com/p/python-for-android/wiki/CrossCompilingPython
其他图
相关文章推荐
- Android中线程的基本用法
- 自己整理的一些Android Studio 常用快捷键
- fragment重叠问题(add hide show方式)
- mac下安装 android模拟器GenyMotion
- android handler 解析
- android系统中DP和SP的转化
- Android开发 Lollipop通知栏图片显示异常的原因及处理
- 编程过程中Android项目中R文件忽然丢失
- Android监听器三种实现方式
- Android集成LeanCloud用户反馈SDK要注意点
- 文章链接
- 配置Android的SDK、NDK、ANT
- Android四大主件之服务Service
- Android笔记(二十五)发送自定义广播和本地广播
- Android学习笔记之:获取Android手机(系统)Root权限介绍
- Android四大主件之广播BroadcastProvider
- Android的selector,Button按钮背景选择器
- android监听器事件
- Android之内容提供器ContentProvider的简单表示
- android开发步步为营之73:Android开发常见问题技术点总结之二