These are not entirely general notes, but often specific to using:. Qt.

PyQt. pyqtdeploy GUI considerations for crossing mobile and desktop platforms This doesn’t make sense unless your app’s GUI is carefully designed to be portable across mobile and desktop platforms. I call this a ‘universal user interface.’ A desktop has, and a mobile platform doesn’t have (?):. multiple overlapping windows. menubar. a file system and file browser A mobile platform has, and a desktop may not have:. multitouch and gestures I’m still experimenting here (but this a principal reason for my app.) I don’t think that Qt provides a magic bullet.

That is, everything you can do in Qt may not be portable and you still might need to have platform specific (mobile versus desktop) code in your app. (And Qt encompasses many tools, such as Qt Quick, which I am ignoring here, but which may be more portable.) Qt considerations for crossing mobile and desktop platforms Printing: Qt does not currently seem to compile the QtPrintSupport module for the mobile platforms. See QTBUG???? Early versions of Android and iOS also did not support printing. Now they do:. iOS: AirPrint.

Android:??? I suppose it just takes time for Qt to adapt to the mobile print frameworks. How do they differ from desktop print frameworks? How many dev machines do you need for cross platform development?

Suppose your software development process includes these steps:. development (creating new features and fixing bugs). deployment (packaging). testing You might want a machine dedicated to each step (so you don’t need to worry about cross contamination.) Probably you want a Mac for your deployment machine. A real Mac can deploy to iOS, Android, and MacOS.

You can also create virtual machines (Ubuntu and Windows) on that Mac so that it can also deploy to those platforms. In other words, a Mac can deploy to all platforms supported by Qt. The reverse is not true.

No other platform will let you deploy to iOS since you are not legally permitted to create a MacOS virtual machine on anything other than a real Mac machine, and since Xcode runs only on a Mac, and since only Xcode lets you develop for iOS (with exceptions such as HTML5/Javascript?) Note that Qt does not currently support WindowsRT (Metro). That’s of little use anyway, since that platform is trailing in the market? The latest pyqtdeploy user guide has a discussion about directory structures that enable sharing of data across target deployment processes. Favoring Qt over Python modules for crossing platforms In your code, you should favor using Qt classes over using Python modules.

For example, use Qt’s support for file system operations over Python’s support. More specifically, try not to use the os module (which drags in many other Python modules) of Python. The reason is, as of this writing, the Python organization does not support mobile platforms. You may have difficulty cross compiling Python modules to mobile platforms (which you must do when you use pyqtdeploy.) Also, you will package Qt libraries with your app, and also packaging Python modules that do the same thing is superflous. Emulators and Simulators for Mobile Devices To test a mobile app without a real device you can use:. Android emulator (AVD). iOS simulator Note the difference.

An AVD is an emulator, presenting the ARM ABI (the interface of the target hardware). It executes the same binary that will run on a real device. Pragmatically, you only need to compile your app once, for the ARM ABI.

The iOS simulator is a simulator, presenting the iOS API (the interface of the target OS.) It executes a binary that is compiled for the i386 ABI, which is not the same ABI as real devices (ARM.) Pragmatically, this means you need to compile your app for both ABI’s (if you want to test on the simulator.). These are general notes and links for this subject.

In other words, this is a table of contents. Many links are often specific to a target platform.

Some of the links to my posts are to incomplete drafts. Also, I edit these blogs periodically, since pyqtdeploy is actively developed and I am learning too. It is best to consult source documentation. Cross-platform and Localization/Internationalization/i18n You want the largest possible audience or market.

You are using Qt because it:. is cross platform. is cross language: supports localization ( internationalization) You increase your audience by porting to new platforms AND by localizing to new languages. Contents Original (source) documentation General Target Linux and MacOS Target iOS Target Android Localization Universal user interface.

Rehash You have:. set up your dev machine and built static libraries. pyqtdeployed your app so it is ready to deploy This part discusses:. deploying your app to a test target machine. debugging your app More about pyqtdeploy work flow The pyqtdeploy GUI lets you choose your work flow. That is, in the ‘Build’ step, you can choose optional steps: qmake, make, ‘run app’. For example, you can choose none of those, and Build will only create file.

Necessitas Sdk For Mac

Then you can switch to:. the command line. or Qt Creator (a GUI app) and resume the work flow (qmake, make, deploying, and running.) (I’m haven’t tried ‘run’ in pyqtdeploy for target Android, I always switch to another tool.) pyqtdeploy developer notes The pyqtdeploy directory contains a file DeveloperNotes.txt. These notes are by the developer of pyqtdeploy but are useful hints about Android development. The author of the notes has said the notes are NOT definitive and should be used with care. I have found typos there. Deploying using the command line Follow the instructions in the developer notes.

I.e.: # Assert you ran qmake and make in pyqtdeploy, but not run # cd to dir that pyqtdeploy created cd /hellobuild/build export ANDROIDNDKROOT=$HOME/android-ndk-r10 export ANDROIDSDKROOT=$HOME/android-sdk-linux # configure install make install INSTALLROOT=deploy # make deployable /home/bootch/Qt/5.3/androidarmv7/bin/androiddeployqt -input -output deploy # deploy adb install -r deploy/bin/QtApp-debug.apk echo Now go to AVD and run app This only installs your app to a target device. You subsequently must use the target device’s GUI to run your app. If you get: Failure INSTALLFAILEDALREADYEXISTS this means you omitted the -r flag, which means reinstall. An alternative is to manually uninstall the app first (on the device, choose SettingsApps, then select your app, then choose the Uninstall button.) Deploying using Qt Creator When you choose the ‘Run’ icon in Qt Creator, it builds, deploys, and runs your app. So it is more automated, but harder to understand what Qt Creator is actually doing on your behalf. Debugging pyqtdeployed apps on android First, refresh the tools The tools (especially pqytdeploy, SIP, and PyQt but also Qt and Python) are updated frequently. You should use the latest versions, which may have fixed some Android crashes.

Remember that pyqtdeploy is the tool that helps build static Python, etc. So if you update pyqtdeploy, you should probably rebuild static Python starting with invoking pyqtdeploy (so that any new patches known by pyqtdeploy are applied.) Stderr and Android logcat Unfortunately, Python prints exceptions to stdout/stderr. These by default are dedirected to /dev/null on Android (which means they disappear.) On android, the system log is called ‘logcat’.

To see it remotely: adb logcat logcat.tmp Ctl-C vi logcat.tmp Its a circular file. Fileness means it persists (even across your debugging sessions.) Circular means it wraps around, overwriting older data. Pragmatically, one debug session never seems to wrap around on itself. The end of the file is always the latest log entries?

Mediagear all cards drivers for mac. You can clear it by rebooting the device (powering it off.) Redirecting stderr to logcat You should be able to configure your target device to redirect stdout and stderr to logcat. To do this requires:.

a rooted real device. an AVD (virtual device) An AVD is always rooted (you have superuser privileges to bypass all security and do what you want). Rooting a real device is an adventure unto itself, so I chose not to do it yet. But the advantage is that a real device eliminates the simulator layer, and is quicker to boot and so forth than an AVD. You can still do certain debugging on an un-rooted real device, you just won’t be able to see Python exceptions directed to stderr.!!! If a device is not rooted, the adb commands to redirect stdio fail quietly.

So you still won’t see stderr in the logcat. To do it you can:. issue adb commands. create a persistent configuration file adb commands to redirect stdout/stderr adb shell stop adb shell setprop log.redirect-stdio true adb shell start Remember this doesn’t persist if you reboot the device (whether and AVD or a real device.) If the device is rooted real device, you must precede that with adb root. (AVD’s are always rooted, so adb root is not necessary.) Debugging methods Traditional choices:. use a debugger such as gdb (which is built into Qt Creator).

harness code with print statements. simple code analysis using crash dumps and Python exception tracebacks It depends on where the bugs are:. in the Python interpreter. in your pyqtdeploy build process. in your app’s Python code It is not uncommon to find bugs in the Python interpreter, since the Android platform is not supported by

(the pyqtdeploy process patches the Python interpreter, and you might find that another patch is required.) The pyqtdeploy build process is intricate. It is not uncommmon to find that you have not frozen a needed Python module (and then you might get an ImportError exception.) Once you get as far as running your own app’s Python code, you probably have installed an exception hook, and can display the exception and traceback on the GUI of the device. (But probably, you are only porting to Android, and have worked out most of your app’s bugs on another platform, except for any Android specific code.) Harnessing pyqtdeploy apps on android I experienced the need to harness (since my app seemed to crash before Qt Creator’s debugger could even get started properly and without any Python exceptions.) This means writing C code. You can use:. qWarning C function. It is properly redirected to Android logcat. androidlog foo C function.

If you need to harness the Python interpreter, you might need to study how to write Python extensions, for example to convert a PyObject. to a representation that is a C string suitable for qWarning. I harnessed pyqtdeploystart.cpp and Python/import.c. Here is the code I used: TODO Building a debug version of Python reading an Android crash dump packaging using Qt Creator. This is a log of setting up a development environment.

I am using Ubuntu 14.04. My ultimate goal is to use pyqtdeploy to distribute a (Python, PyQt, Qt) app to Android (and iOS.) Installing QtCreator QtCreator is a cross platform IDE.

I have been using Eclipse and PyDev, but QtCreator might be better, since it comes from the Qt project. ( This explains that the version 3.0.1 of QtCreator shipped with Ubuntu 14.04 will give the error message: Project ERROR: You need to set the ANDROIDNDKROOT environment variable so I downloaded a later version of QtCreator 3.1.0. You can’t just use sudo apt-get install qtcreator. In my experience, Ubuntu lags behind on Qt, and Qt changes rapidly, so it is worthwhile to download the latest Qt.) At I chose the ‘Qt Online Installer’, and the file ‘qt-opensource-linux-x86-1.6.0-4-online’ was downloaded. Then give it execute permission and click on the downloaded file. The ‘Qt Setup Wizard’ app opens.

Accept the defaults, and newer versions of Qt and Qt Creator will be downloaded to /Qt directory. (This will include the Qt library built for ARM i.e.


For Android.) (As, Qt is supports iOS, but QtCreator doesn’t support iOS directly, you will need to use file AND the Apple Xcode IDE for that. This blog may apply to using OSX as the host and cross compiling to Android.) Install more tool chain Qt Creator (when cross compiling for Android) relies on:. Android SDK. Android NDK. ant. JDK Installing Android SDK Navigate your browser to the. Under ‘ SDK Tools Only‘, choose a package to download.

(I don’t want a package that includes the Eclipse IDE or the newer ‘Android Studio’ IDE, since I am using the QtCreator IDE.) Extract the package, say to your home directory. Refreshing the Android SDK Now you have just the basics,.

You use the ‘Android SDK Manager’ to download more. It is a package manager.

You can start it from a command line: cd /android./tools./android sdk A GUI app will open. It lets you browse a tree directory of packages to install. It will open with an appropriate set (the latest) packages you need to download. That includes:. Android SDK Platform-tools. Android SDK Build-tools.

a version of the Android API I unselected the latest version of the Android API (Android L, API 20 preview) and selected the next API (since I don’t want to mess with a possibly unstable API.) Now choose the ‘Install packages ‘button. Downloading the Android NDK The SDK is for developing in Java. You need the NDK for developing in C.

Navigate your browser to the. Choose the download for your host word length (32-bit or 64-bit) (in my case, 32-bit Ubuntu 14.04) and for your target Android word length (in my case, 32-bit, since I am just testing and have no specific target device in mind.) Extract the download, say to your home directory. Installing Ant (I’m not sure what kind of tool ant is.) sudo apt-get install ant Install a JDK You can use the Ubuntu Software Center to find the name of the package and download it. Search for ‘JDK’ and also choose ‘Show xxx technical items’ near the bottom. I chose openjdk-7-jdk, but clicking the ‘Install’ button didn’t seem to work, so sudo apt-get install openjdk-7-jdk Configure QtCreator to use the tool chain: SDK, NDK, ant, and JDK Start QtCreator and choose ToolsOptionsAndroid.

Click the ‘Browse’ buttons and navigate to the location where you downloaded the tools. (For many of them, Qt Creator leads you to the right place, but for the JDK I had to navigate to /usr/lib/jvm/java-7-openjdk-i386. Configure QtCreator to use the Android kit Choose ToolsOptionsBuild&Run. Choose ‘Android for armeabi-v7a (GCC 4.8, Qt 5.3.1)’, which is auto-detected. Create an example Project I followed this. I don’t really want to use QtQuick, but this is just an example.

(I also took shortcuts with the example. Instead of displaying an SVG file and moving it, I just displayed the white rect that appears in the default QML.) After creating the project, I clicked on the ‘Run’ icon. Now it says that I do not have an Android device. It offered to create one for me (a ‘Create Android Virtual Device’ button.) I clicked on that, entered a name for the device, and clicked OK. Then I got an error: ‘Error: invalid –tag default ’ (I suppose it is a bug in QtCreator that might be finessed by different choices.) But I decided to use Android tools to create an AVD. Create an AVD using the Android AVD Manager tool An AVD is a simulator, or Android virtual device.

The Android project provides a tool ‘Android Virtual Device Manager’ for creating them. cd /android./tools./android avd A GUI app will open. Create an AVD. (Glossing the details, but the defaults usually work, and for a clean development machine, you will only see the choices from the things you installed earlier.) I suppose the list of AVD’s is in a standard place that QtCreator knows about. Testing Now in QtCreator when I click the Run button, it:. lets me chose the AVD I just created.

proceeds to build,. starts the AVD. downloads my app to the AVD It takes a while for the AVD to boot itself. For a while you may see a black screen or a green arc going in circles. I don’t think the app can load while it is booting. (When it finishes booting, you can interact with the AVD like a real phone, using the mouse.

It seems to start in Android’s ‘Getting Started’ help screens (several screens telling you that a swipe does) just as if you had just powered up a newly purchased and activated phone.) I suppose QtCreator timed out waiting for the AVD to boot. I got: Unable to start 'org.qtproject.example.accelbubble'. But the AVD kept running. I tried the Run button again.

This time, the application seemed to start on the AVD: it displayed a white rectangle. I tried to click with the mouse in the app to close it, that didn’t work. A swipe with the mouse (pressing the LMB while moving) killed the app in the AVD.,. Context: you are a Python developer. You want to port your app to the Android platform. You are confused about the many projects that provide tools for this purpose.

Disclaimer: this is a work in progress. It is a log of what I learned trying to make sense of the subject.

Python on Android Python is a language. Android is a platform. Most development for the Android platform is in the Java language. It is rare to develop for the Android platform in the Python language. You probably develop your Python app using tools on a development machine where Python is well supported. To port your Python app to Android, you need other tools.

Tool Projects for Python on Android Developers create tools for porting Python to Android and publish projects for the tools:. There is some duplication/sharing between projects. The projects have similar names but are distinct projects! The projects differ in:.

what tools they provide. what development environment they support. whether they are active and supported PY4A This project is about compiling (for Android):.

the Python interpreter. Python modules The result is not very useful on its own, since the result doesn’t include much IO to a user on the Android platform (because the notion of stdin/stdout/stderr to a console is not in Android?) The result is very useful as a component in the other tool projects. Most developers don’t need to understand this project, unless they have custom (non-standard, C language (not pure Python)) Python modules that need to be compiled for Android. The essential contribution of this project is:. the scripts (business process) for compiling Python interpreter and modules using the Android NDK.

patches to the Python interpreter, needed because of differences in libc on Android? This project is probably stable and relatively inactive. Once the project ports a particular version of Python to Android, the project is done until another version of Python is released (or the Android platform changes?) SL4A TODO Android-python27 This project is about packaging (for Android):. an app written in Python. that uses minimal services of the Android platform???????

The project includes an Eclipse project that can be imported into Eclipse IDE. After telling Eclipse to build, the result is an Android package.

Necessitas Sdk For Mac

Necessitas sdk for mac

The project also includes source directories from other the other tool projects. It is not clear how to combine them? The project does not include an Eclipse project for packaging a Python app that uses Qt? It requires a certain amount of hacking? Python for Android This project is about packaging (for Android):.

an app written in Python. that uses the Kivy cross-platform GUI toolkit. that uses services of the Android platform (that are not available through the GUI toolkit) The development environment for this project is a Linux machine, using a command line. Contributions:. scripts (business processes) for compiling components ( scripts for packaging (

a binding from Python to/from Java (pyjnius). Kivy cross-platform GUI toolkit This project seems to suffer from a language/culture barrier. The project documentation in English seems like poor technical writing. TODO who should use this project PyDroid This project is about packaging (for Android):. an app written in Python. that uses the Qt cross-platform GUI toolkit and the PySide binding to Qt The development environment for this project is a Linux machine, using a command line. The project IS a python package.

You install it like you would any other Python package. To use the project, you execute ‘helper’ or tool programs (scripts written in Python). For example: pydroid check The project depends on TODO. During the installation of this project, it checks the dependencies?

These are instructions to create the installer framework Build To build an installer, it is advised to use a statically linked Qt.