Hello World Android Application with Swipe View UI Using Qt
Welcome to the Hello World Android Application project! This repository contains the source code and detailed steps for building a simple "Hello World" Android app with a swipe view UI using Qt. The project demonstrates the basics of setting up a development environment, building an Android application with Qt, and deploying it to an emulator or device. Table of Contents
Introduction
Features
Prerequisites
Development Steps
1. Set Up the Development Environment
2. Create the Application
3. Build & pa ckage the Application
4. Deploy on Emulator or Device
Repository Structure
Introduction
This project is a basic Android application developed using Qt that demonstrates:
Swipe navigation between multiple views.
Building and deploying Qt applications for Android.
The app is packaged as an APK and can be deployed to an emulator or physical device for testing. Features
Swipe View UI: Navigate between multiple views using swipe gestures.
Simple Design: Displays a "Hello World" message on each view.
Cross-Platform Development: Built using Qt for Android.
Prerequisites
Ensure you have the following installed and configured:
Operating System: Linux (e.g., Ubuntu)
Qt Framework: Download and install Qt with Android support from Qt Downloads.
Android SDK and NDK: Install the required SDK tools, platforms, and NDK.
Build Tools:
CMake
adb (Android Debug Bridge)
Android toolchain (for cross-compilation)
Development Steps
-
Set Up the Development Environment
Install Qt And settup it: sudo apt update Download the necessary components for Android development from the Qt Maintenance Tool. wget https://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run chmod +x qt-unified-linux-x64-online.run ./qt-unified-linux-x64-online.run apt install libxcb-cursor0 libxcb-cursor-dev' sudo apt install build-essential openjdk-17-jdk unzip git cmake ninja-build libgl1-mesa-dev -y
wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip unzip commandlinetools-linux-9477386_latest.zip -d $HOME/Android export ANDROID_HOME=$HOME/Android export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH mkdir -p $ANDROID_HOME/cmdline-tools/latest mv $ANDROID_HOME/cmdline-tools $ANDROID_HOME/cmdline-tools/latest sdkmanager --channel=3 "platform-tools" "platforms;android-33" "build-tools;33.0.0" "ndk;26.1.10909125"install neccessary tool and library with MaintenanceTool like this:
Configure the Qt Android Toolchain: Open Qt Creator. Navigate to Prefrence > Kits > Android. Set the paths for Android SDK, NDK, JDK, and ant. like these photos:
-
Create the Application
Create a new Qt Quick Application project in Qt Creator: File > New Project > Application (Qt Quick) > Swipe View UI. Use a basic template or design your views manually.
Implement swipe navigation: Use SwipeView from Qt Quick Controls. Example:
SwipeView { id: swipeView anchors.fill: parent Page { Label { anchors.centerIn: parent text: "Hello, World! Page 1" } } Page { Label { anchors.centerIn: parent text: "Hello, World! Page 2" } } Page { Label { anchors.centerIn: parent text: "Hello, World! Page 3" } } }
-
Build & Package the Application
Select the Android Kit in Qt Creator. Configure the build system: Use CMake for project configuration. Build the project: /opt/Qt/Tools/CMake/bin/cmake --build /root/HelloWorldSwipe/build/Android_Qt_6_8_0_Clang_arm64_v8a-Debug --target all /opt/Qt/6.8.0/gcc_64/bin/androiddeployqt --input /root/HelloWorldSwipe/build/Android_Qt_6_8_0_Clang_arm64_v8a-Debug/android-appHelloWorldSwipe-deployment-settings.json --output /root/HelloWorldSwipe/build/Android_Qt_6_8_0_Clang_arm64_v8a- Debug/android-build-appHelloWorldSwipe --android-platform android-34 --jdk /usr/lib/jvm/java-1.17.0-openjdk-amd64 --gradle
-
Deploy on Emulator or Device
Verify functionality on the emulator or physical device: Launch the app and test swipe functionality.
Repository Structure /project-root ├── /src # Source code of the application ├── /build # Build output directory ├── /resources # Images, icons, and other resources ├── /docs # Documentation and guides └── README.md # Project documentation