Requirements for Android application development with Kanzi

When you are developing Kanzi applications for Android you can use Android Studio, the Clang toolchain, and the Gradle build system. This development approach is tested on:

  • Ubuntu/Linux 18.04.1

  • Windows 10

To develop Android applications with Kanzi, you need Android Studio, version Electric Eel or newer. You can download it from https://developer.android.com/studio.

Kanzi Android application templates are compatible with:

  • Gradle 7.6.2

  • Android Gradle plugin 7.4.2

  • JDK 17. See Installing JDK.

  • CMake 3.10.2.4988404

Using other versions of these tools require manual adjustments to your project. For an example of use of more recent tools, see Jetpack Compose example.

Kanzi provides two Android frameworks with different features and requirements. See Developing Kanzi applications for Android.

Kanzi Android framework (droidfw) requires:

  • Android API 26 or higher

  • Android 8 or higher

  • Java language level 8 (1.8) or higher

  • NDK 21.3.6528147

Kanzi application framework (appfw) requires:

  • Android API 21 or higher

  • Android 5 or higher

  • Java language level 7 (1.7) or higher

  • NDK 21.3.6528147

To use Android features in Kanzi Studio, such as deployment of projects to Android devices and import of Java Kanzi Engine plugins, you need 64-bit JDK 17. See Setting up Android environment for Kanzi Studio.

Note that you can use Java plugins only with Kanzi Android framework (droidfw) applications.

To deploy to the Android Emulator an application that uses OpenGL ES API level higher than 2.0, in the Android Emulator enable OpenGL ES 3.0. See Enabling OpenGL ES 3.0 in the Android Emulator.

Setting up Android Studio environment

Installing JDK

Android Studio comes with JDK that it usually installs to C:\Program Files\Android\Android Studio\jbr or C:\Users\<user>\AppData\Local\Programs\Android Studio\jbr.

The version of built-in JDK can vary with the version of the Android Studio, and might not be compatible with your project’s Gradle tooling. See Troubleshooting Android application development with Kanzi.

To install a specific JDK version and use it for a specific Android Studio project:

  1. In Android Studio, open the Android application of your Kanzi project.

  2. In the main menu, select File > Settings.

  3. In the Settings window, select Build, Execution, Deployment > Build Tools > Gradle, and set Gradle JDK to Download JDK.

  4. In the Download JDK window, set:

    • Version to the version that you want to use. Kanzi Android templates are compatible with JDK 17.

    • Vendor to a trusted source. For example, Eclipse Temurin (AdoptOpenJDK Hotspot).

    Click Download.

  5. Synchronize your project with Gradle.

Installing native build tools

To install native build tools for Android Studio:

  1. In the Android Studio Welcome screen, select More Actions > SDK Manager.

  2. In the SDK Manager window in the SDK Tools tab, select:

    • NDK 21.3.6528147

    • CMake 3.10.2.4988404

    Click OK.

Setting up Android environment for Kanzi Studio

You must set up the Android environment for Kanzi Studio to use Android and Java functionality in Kanzi Studio.

To set up Android environment for Kanzi Studio:

  1. In Kanzi Studio in the main menu, select Edit > User Preferences and in the Advanced tab click Open Build Environment Configuration.

    ../../_images/open-build-environment-configuration.png
  2. In the Build Environment Configuration dialog make sure that these environment variables are correctly set:

    • ANDROID_HOME to the location of your Android SDK installation

      For example, C:\Users\<user>\AppData\Local\Android\Sdk.

    • (Optional) ANDROID_STUDIO to the location of your Android Studio installation

      Kanzi Studio uses this environment variable to open Kanzi applications for Android in Android Studio. For example, when you open Code Behind source from the Activity Browser.

      If not set, Kanzi Studio looks for Android Studio at C:\Program Files\Android\Android Studio\bin\studio64.exe.

    • JAVA_HOME to the location of your 64-bit JDK 17 installation

      You can use the JDK that you installed with Android Studio. See Installing JDK.

      Alternatively, you can install a standalone JDK. For example, from https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_x64_windows_hotspot_17.0.8.1_1.zip.

    Kanzi Studio stores the environment variables in the %ProgramData%\Rightware\<KanziVersion>\kanzi_environment_variables.bat file. The Kanzi Command Prompt uses the environment variables set in this file. See Using the Kanzi Command Prompt.

Kanzi Android build process

This diagram shows the process that Kanzi uses to build an Android package.

../../_images/gradle-build.svg