< Android Revision as of 07:11, 15 June 2016 (view source)Cola (talk | contribs) (add some nice useful tricks)← Older edit Latest revision as of 21:56, 19 May 2020 (view source) Nicolas Fella (talk | contribs) Line 69: Line 69: * Java platform 7 is needed (both JRE and JDK). One can select the Java platform versions e.g. with <code>update-alternatives --config java</code> and <code>update-alternatives --config javac</code> * Java platform 7 is needed (both JRE and JDK). One can select the Java platform versions e.g. with <code>update-alternatives --config java</code> and <code>update-alternatives --config javac</code> * Use <code>jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'</code> to find the JAVA_HOME * Use <code>jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'</code> to find the JAVA_HOME − −== Android Emulator for Unit Tests == −For running unit tests, especially on a CI, either one can run the tests in an emulator or on a physical device. In the following, we explain how to create an AVD (Android Virtual Device) and how to start the emulator from the Android SDK. − −==== Create AVD (Android Virtual Device) ==== −Within this device, the unit tests are executed. For this we use the AVD Manager: −* Check available targets: −<syntaxhighlight lang="bash"> −$ANDROID_SDK_ROOT/tools/android list targets −</syntaxhighlight> −* Create AVD (directly tell to not use custom hardware profile): −<syntaxhighlight lang="bash"> −echo no | $ANDROID_SDK_ROOT/tools/android create avd --name myandroid22 -t "android-22" --abi "default/armeabi-v7a" −</syntaxhighlight> −These commands should have created an AVD called '''myandroid22'''. You can check all available AVDs: −<syntaxhighlight lang="bash"> −$ANDROID_SDK_ROOT/tools/android list avd −</syntaxhighlight> − −==== Start Emulator ==== −Running the emulator in a headless mode (without display): −<syntaxhighlight lang="bash"> −$ANDROID_SDK_ROOT/tools/emulator64-arm -avd myandroid22 -no-skin -no-audio -no-window −</syntaxhighlight> −* The '-no-skin' option removes the emulator buttons such as the home and other hardware keyboard buttons. −* The '-no-audio' option disables the audio support. −* The '-no-window' option disables the emulator's graphical window display. − −One can check which emulators are running by listing the available devices: −<syntaxhighlight lang="bash"> −$ANDROID_SDK_ROOT/platform-tools/adb devices −</syntaxhighlight> − −==== Further Reading ==== −* AVD command line Documentation: http://developer.android.com/tools/devices/managing-avds-cmdline.html −* Emulator Documentation: http://developer.android.com/tools/help/emulator.html −* Emulator tutorial: http://developer.android.com/tools/devices/emulator.html − −== Trouble Shooting == −* enable debug output on the device −** get all output: adb -e logcat −** fine tuning: [https://developer.android.com/studio/command-line/logcat.html] −* call applications with command line parameters: −** Qt on Android defines the extra key "applicationArguments" with is passed as input parameter to your application (see [http://code.qt.io/cgit/qt/qtbase.git/tree/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java#n652]) −** usage like: −<syntaxhighlight lang="bash"> −adb shell am start -e applicationArguments "-v" -n <packageName>/org.qtproject.qt5.android.bindings.QtActivity −</syntaxhighlight> Latest revision as of 21:56, 19 May 2020 Setup Environment for KDE on Android Development In the following, we explain how to setup a build environment on a Linux system to be able to compile Qt and in particular KF5-based application for Android. Prerequisites / Setup of Cross-Compiling Build System At first we prepare your system with all necessary packages to build your application for Android. For this tutorial we assume that everything is done in the folder /opt/android/ (you can adapt the tutorial accordingly when using another folder). Some 32 bit system libraries are required for the host system (because some tools are 32 bit): libgcc, zlib, libc installing on Debian based system: dpkg --add-architecture i386 apt-get install zlib1g:i386 libgcc1:i386 libc6:i386 Extra-CMake-Modules we require at least version >= 5.15 due to https://git.reviewboard.kde.org/r/125183 you can also use a smaller version >= 1.7.0 if applying this change directly to your cmake files Android SDK Download: http://developer.android.com/sdk/index.html to /opt/android/ Unpack, run "tools/android update sdk" and select the following packages: Android SDK Tools (24.3.4) Android SDK Platform-tools (23.0.1) Android SDK Build-tools (22.0.1) Android 5.1.1 (API 22): SDK Platform (only "SDK Platform" needed, i.e. no docs, samples or sources) sys-img-armeabi-v7a-android-22 (required for emulator and unit tests) result: now the SDK should be installed in /opt/android/android-sdk-linux Android NDK Download: https://developer.android.com/ndk/index.html to /opt/android/ unpack the package (see the instructions on the download page) result: now the NDK should be installed in /opt/android/android-ndk-r10e Qt with support for Android devices Download the Qt 5.5.0 for Android: https://www.qt.io/download-open-source/#section-2 (32-bit or 64-bit as it fits your host system; usually 64-bit) Variant 1: Offline Installers ("Skip" can be used without problem when asked to register an account) Variant 2: Online installer ("Skip" can be used without problem when asked to register an account) install the following components to /opt/android/Qt5.5.0: Android armv7 Qt Creator 3.4.2 (cannot be disabled, some of its tools are used from other parts) Recommended components: Qt Quick Controls Qt Location Qt Script Optional components (there might be KDE software using it): Qt WebEngine Qt Canvas 3D Qt3D Qt Quick 1 Install the following software packages on your host system from your package manager (if not yet installed): CMake: >= 2.8.6 Java Development Kit 7 (openjdk-7-jdk) Ant Environment Variables The build environment is the name for the shell in that the application is build. The shell is prepared by exporting a series of environment variables that then are picked up by the build scripts. export ADIR=/opt/android export ANDROID_NDK=$ADIR/android-ndk-r10e # note the _ROOT postfix here, different pattern export ANDROID_SDK_ROOT=$ADIR/android-sdk-linux export Qt5_android=$ADIR/Qt5.5.0/5.5/android_armv7/ export PATH=$ADIR/android-sdk-linux/platform-tools/:$PATH # adapt the following path to your ant installation export ANT=/usr/bin/ant # adapt the following path to your openjdk location, eg: # openSUSE: /usr/lib64/jvm/java (needs default version being properly set, see notes below) # Debian: /usr/lib/jvm/java-7-openjdk-amd64 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk/ Some notes: /opt/android should be replaced with the custom build folder selected by you Java platform 7 is needed (both JRE and JDK). One can select the Java platform versions e.g. with update-alternatives --config java and update-alternatives --config javac Use jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));' to find the JAVA_HOME Retrieved from "https://community.kde.org/index.php?title=Android/Environment&oldid=88298" This page was last edited on 19 May 2020, at 21:56. Content is available under Creative Commons License SA 4.0 unless otherwise noted.