Giter Club home page Giter Club logo

qml-android-demo's Introduction

QML for Android Demo

This is just a Hello World application, I (Calin Cruceru) wrote in QML and configured with CMake, to allow deploying on different OSs/architectures: Android, Linux, Windows, MacOS (adding iOS support would only imply copying the toolchain file from here, but since I couldn't test it, I skipped this step).

What is nice about such a trivial application is that it is a good example for those who want to develop cross-platform QML applications using CMake (there are few such examples out there).

Directory structure

  • android - files needed by any android application. Similar dirs should be added for each platform (e.g. iOS);
  • platforms - toolchain files specific to each platform and loaded by CMake when cross-compiling. For more details about toolchain files check out CMake's documentation;
  • src - all project's source files;

Each directory contains its on README file, so press each one for more details.

Configuration

Before getting the application working, a couple of dependencies must be solved.

First, you will need Android SDK and Android NDK. Make sure you download the latest versions. Also, you will need ant. Add all these to your PATH.

Then, you will need Qt5 installed for both your host machine and for android/ios if you are planning to deploy the application on these OSs. These two links should guide you to do that:

Make sure to add the installation dir for each to your PATH. Then, add these exports to your .bashrc/.zshrc and you should be all set up:

export JAVA_HOME=<path to your jdk root dir>
export ANDROID_HOME=<path to your android-sdk dir>
export ANDROID_SDK=<path to your android-sdk dir>
export ANDROID_NDK=<path to your android-ndk dir>
export ANDROID_NDK_TOOLCHAIN_ROOT=<path to your android-ndk/toolchains dir>

export Qt5_host=<path to your host Qt5  installation dir>
export Qt5_android=<path to yout android Qt5 installation dir>

Alternatively, if you are on ArchLinux, install Qt5 from the official repos and install android-qt5-armeabiv7a from AUR. It will install all its dependencies, including Android SDK/NDK.

These are my exports after installing the above mentioned packages:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
export ANDROID_HOME=/opt/android-sdk
export ANDROID_SDK=/opt/android-sdk
export ANDROID_NDK=/opt/android-ndk
export ANDROID_NDK_TOOLCHAIN_ROOT=/opt/android-ndk/toolchains
export Qt5_host=/usr
export Qt5_android=/opt/android-qt5/5.5.1/armeabi-v7a

export PATH="/opt/android-sdk/tools:$PATH"
export PATH="/opt/android-qt5/5.5.1/armeabi-v7a/bin:$PATH"

Install

Installation depends on whether you want to get the application working on your own machine or some external device (Android devices are the only option in this example).

To generate the executable for your own machine (be it a Linux/Windows/MacOS):

cd ~
git clone https://github.com/calincru/QML-Android-Demo
mkdir QML-Android-Demo/build
cd QML-Android-Demo/build
cmake ..
make

I used bash syntax, but it's easy to adapt it to other shells. It should create an executable named Demo in ~/QML-Android-Demo/build/bin.

To generate the .apk file for an Android device:

cd ~
git clone https://github.com/calincru/QML-Android-Demo
mkdir QML-Android-Demo/build
cd QML-Android-Demo/build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../platforms/android.cmake -Wno-dev
make
make apk_debug

It should create a .apk file in ~/QML-Android-Demo/build/android/bin. To deploy it to your Android mobile phone, simply connect it to your PC via USB and type in your console adb install -r ~/QML-Android-Demo/build/android/bin/<name_of_the_apk_file>.

qml-android-demo's People

Contributors

calincru avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.