diff --git a/minuetandroid/CMakeLists.txt b/minuetandroid/CMakeLists.txt new file mode 100644 index 0000000..900446b --- /dev/null +++ b/minuetandroid/CMakeLists.txt @@ -0,0 +1,7 @@ +#cmake_minimum_required(VERSION 3.3.2 FATAL_ERROR)#Currently I am using this version + +project(minuetandroid) + +#requirements + +add_subdirectory(src) diff --git a/minuetandroid/README b/minuetandroid/README new file mode 100644 index 0000000..a0338de --- /dev/null +++ b/minuetandroid/README @@ -0,0 +1,48 @@ +Hello KWorld +============ + +Small example "Hello world" app for creating a Qt-based app with CMake and ECM for Android. + +Prerequisites +------------- +Setup of Android development environment, see https://community.kde.org/Android/Environment +ECM >= 5.17.0 installed + +Instructions +------------ + +Prepare build dir and product dir, starting from toplevel dir of this project: + export minuetandroid_DIR=`pwd` + mkdir -p ../export/minuetandroid + cd ../export/minuetandroid + export minuetandroid_PRODUCT_DIR=`pwd` + mkdir -p ../../build/minuetandroid + cd ../../build/minuetandroid + +Configure the build: + cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH="${Qt5_android}" \ + -DCMAKE_INSTALL_PREFIX="${minuetandroid_PRODUCT_DIR}" \ + -DQTANDROID_EXPORTED_TARGET=minuetandroid \ + -DANDROID_APK_DIR="${minuetandroid_DIR}"/data \ + "${minuetandroid_DIR}" + +CMAKE_TOOLCHAIN_FILE: see http://api.kde.org/ecm/toolchain/Android.html +CMAKE_INSTALL_PREFIX: needs to be absolute path currently +QTANDROID_EXPORTED_TARGET & ANDROID_APK_DIR: see http://api.kde.org/ecm/toolchain/Android.html, "Deploying Qt Applications" + +Build and install the result in the product dir: + make install/strip +"install/strip" makes sure the binaries only have minimal stuff needed to run. + +Workaround for ECM < 5.22: +ECM/toolchain/Android.cmake expects some dirs to exist. so manually create them now: +# mkdir "${minuetandroid_PRODUCT_DIR}"/share + mkdir -p "${minuetandroid_PRODUCT_DIR}"/lib/qml + +Create the APK finally: + make create-apk-minuetandroid + +Deploy it, e.g. via android debugger: + adb install -r minuetandroid_build_apk/bin/QtApp-debug.apk diff --git a/minuetandroid/commands.txt b/minuetandroid/commands.txt new file mode 100644 index 0000000..bf63fab --- /dev/null +++ b/minuetandroid/commands.txt @@ -0,0 +1,71 @@ +#Step 1 check list for the list of libraries installed +ndk +sdk +ant +java(open jdk) + +#Step 2 you need to have all these libraries else follow the instructions given on kde -->building kf5 for android +cd /home/ayush/android #(this was my path to keep it along with ndk and sdk) +git clone git://anongit.kde.org/scratch/cordlandwehr/kdesrc-conf-android.git +mkdir -p extragear/kdesrc-build +git clone git://anongit.kde.org/kdesrc-build extragear/kdesrc-build +ln -s extragear/kdesrc-build/kdesrc-build kdesrc-build +ln -s kdesrc-conf-android/kdesrc-buildrc kdesrc-buildrc + +#Step 3 Now open the kdesrc-buildrc file in any text editor and change the following lines: +line 15: -DCMAKE_PREFIX_PATH= "path to Qt5 Android libraries. Example: /home/ayush/Qt5.5/5.5/android_armv7" + + +#Step 4 setting up the commands either put it in terminal or ~bashrc +export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk +export ANT=/usr/bin/ant +export Qt5_android=/home/ayush/Qt5.5.1/5.5/android_armv7 +export ANDROID_SDK_ROOT=/home/ayush/android/android-sdk-linux/ +export PATH=$ANDROID_SDK_ROOT/platform-tools/:$PATH +export ANDROID_NDK=/home/ayush/android/android-ndk-r10e/ + +#Step 5 once done run the script + ./kdesrc-build libintl-lite extra-cmake-modules frameworks-android +#note you migh need to be a sudo user for it. +#if you become a sudo operator, you might have to do the step 4 again + +#for creating the applicaiton start from step 6 to end +#be in the home directory of minuet Example /home/ayush/minuet +#Step 6 creating directories +export minuetandroid_DIR=`pwd` +mkdir -p export +cd export/ +export minuetandroid_PRODUCT_DIR=`pwd` + +#not needed any more +#mkdir -p ../../build/minuetandroid +#cd ../../build/minuetandroid + + +#Step 7 cmake commands + cmake "${minuetandroid_DIR}" -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH="${Qt5_android}" \ + -DCMAKE_INSTALL_PREFIX="${minuetandroid_PRODUCT_DIR}" \ + -DQTANDROID_EXPORTED_TARGET=minuetandroid \ + -DANDROID_APK_DIR="${minuetandroid_DIR}"/minuetandroid/data \ + -DKF5I18n_DIR=/opt/android/kde/install/lib/cmake/KF5I18n/ +# -DKF5Config_DIR=/opt/android/kde/install/lib/cmake/KF5Config/ \ +# -DKF5_HOST_TOOLING=/opt/android/kde/install/lib/cmake/KF5Config/ + +#step 8 +make install/strip + + +#mkdir "${minuetandroid_PRODUCT_DIR}"/share + +#Step 9 Compulsory to run the following command else you will get an error . Ecm expects us to have a directory +mkdir -p "${minuetandroid_PRODUCT_DIR}"/lib/qml + +#Step 10 will create an apk +make create-apk-minuetandroid + +#Step 11 install it on your phone ... Android to be specific :P +adb install -r minuetandroid_build_apk/bin/QtApp-debug.apk + +#now you have a simple android application using cmake.... enjoy :) diff --git a/minuetandroid/data/AndroidManifest.xml b/minuetandroid/data/AndroidManifest.xml new file mode 100644 index 0000000..d20bc53 --- /dev/null +++ b/minuetandroid/data/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/minuetandroid/data/res/drawable/minuet.png b/minuetandroid/data/res/drawable/minuet.png new file mode 100644 index 0000000..60796ec Binary files /dev/null and b/minuetandroid/data/res/drawable/minuet.png differ diff --git a/minuetandroid/src/CMakeLists.txt b/minuetandroid/src/CMakeLists.txt new file mode 100644 index 0000000..3cf42d1 --- /dev/null +++ b/minuetandroid/src/CMakeLists.txt @@ -0,0 +1,22 @@ +set(minuetandroid_SRCS + main.cpp +) +qt5_add_resources(minuetandroid_SRCS resources.qrc) + +add_executable(minuetandroid ${minuetandroid_SRCS}) + +target_link_libraries ( + minuetandroid + Qt5::Gui + Qt5::Qml +) + +if (CMAKE_SYSTEM_NAME STREQUAL Android) + target_link_libraries ( + minuetandroid + Qt5::Quick + KF5::I18n + ) +endif() + +install(TARGETS minuetandroid RUNTIME DESTINATION bin) diff --git a/minuetandroid/src/main.cpp b/minuetandroid/src/main.cpp new file mode 100644 index 0000000..d76049d --- /dev/null +++ b/minuetandroid/src/main.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/minuetandroid/src/main.qml b/minuetandroid/src/main.qml new file mode 100644 index 0000000..7d280fc --- /dev/null +++ b/minuetandroid/src/main.qml @@ -0,0 +1,14 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 + +ApplicationWindow { + visible: true + width: 640 + height: 480 + title: qsTr("Hello KWorld") + Label { + text: qsTr("Hello KWorld") + anchors.centerIn: parent + } +} + diff --git a/minuetandroid/src/resources.qrc b/minuetandroid/src/resources.qrc new file mode 100644 index 0000000..5f6483a --- /dev/null +++ b/minuetandroid/src/resources.qrc @@ -0,0 +1,5 @@ + + + main.qml + +