Troubleshooting Android application development with KanziΒΆ

  • When you receive this error while building an Android package:

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app.packageDebug'.
    > Failed to obtain compression information for entry
    

    Make sure that you are using Android Studio version 4.1.3 or newer. This error occurs on Android Studio version 3.1.

  • When you receive this error while building an Android package:

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app.packageDebug'.
    > Java heap space
    

    Increase the available heap amount in the Gradle build system. For example, in Android Studio open the <ProjectName>/Application/configs/platforms/android_gradle project, in that project open the gradle.properties file and set:

    org.gradle.jvmargs=-Xmx4608m
    
  • When you receive this error while building an Android package:

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'Engine\configs\platforms\android_gradle\kanziruntime\build.gradle' line: 103
    
    * What went wrong:
    A problem occurred evaluating project ':kanziruntime'.
    > <PathToKanziWorkspace>\Engine\version.txt not found
    

    In the <ProjectName>/Application/configs/platforms/android_gradle directory of your project create a file called local.properties and in that file set the correct location of your workspace. For example, set:

    kanzi.home=C\:\\<KanziWorkspace>
    
  • When you receive this error while building an Android package:

    > Task :kanziruntime:cmakeInstallNativeLibsRelease FAILED
    'cmake' is not recognized as an internal or external command, operable program or batch file.
    Execution failed for task ':kanziruntime:cmakeInstallNativeLibsRelease'.
    > Process 'command 'cmd finished with non-zero exit value 1
    

    Add the path to the CMake bin directory to your system path. You can find the CMake bin directory in the Android SDK. For example, android-sdk/cmake/3.10.2.4988404/bin.

  • When you receive this warning while building an application that uses the Data_source_plugin_template:

    More than one file was found with OS independent path 'lib/arm64-v8a/libkzcoreui.so'.
    This version of the Android Gradle Plugin chooses the file from the app or dynamic-feature
    module, but this can cause unexpected behavior or errors at runtime. Future versions of
    the Android Gradle Plugin will throw an error in this case
    

    Update the Kanzi Gradle plugin to version 0.7.1.

  • When you receive this error when starting the Preview for a Kanzi Studio project that uses a Java Kanzi Engine plugin:

    Failed to load plugin 'kzjvm.dll'.
    

    For the Kanzi Studio Preview to load a Java Kanzi Engine plugin, the Preview must find the jvm.dll from the local 64-bit JDK. Set either:

    • PATH environment variable to include the directory that contains the jvm.dll from the 64-bit JDK. This can be either:

      • The JDK that is bundled with Android Studio.

        For example, C:\Program Files\Android\Android Studio\jre\bin\server.

      • Your own OpenJDK installation.

        For example, <openjdk>\jre\bin\server.

    • JAVA_HOME environment variable to the 64-bit JDK path and include in the %JAVA_HOME%\bin\server directory the jvm.dll from the 64-bit JDK.

  • When you receive one of these exceptions when running your Android application:

    java.lang.BootstrapMethodError: Exception from call site #0 bootstrap method
    
    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: <process name>, PID: <pid>
    java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)
      at com.rightware.kanzi.KanziViewAdapter.loadStartupPrefab(KanziViewAdapter.java:664)
      at com.rightware.kanzi.KanziViewAdapter.setStartupPrefabUrl(KanziViewAdapter.java:196)
    

    Your application is most likely using an incompatible version of Java. Kanzi Android framework (droidfw) and Kanzi Java API require Java 8 (1.8).

    In the app/build.gradle file of your Android Studio project, ensure that the Java language version is set to a compatible version:

    android {
        ...
    
        compileOptions {
           sourceCompatibility JavaVersion.VERSION_1_8
           targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
  • When using Android Studio to convert a Java project to Kotlin, the default generated gradle script uses the latest version of Kotlin by default. This can result in an error similar to:

    The minCompileSdk (31) specified in a
    dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
    is greater than this module's compileSdkVersion (android-28).
    Dependency: androidx.core:core-ktx:1.8.0-alpha01.
    

    Make sure that the version of Kotlin is compatible with your project. For example, if your project uses compileSdkVersion 28, downgrade Kotlin to version 1.6.0.

    Replace

    implementation "androidx.core:core-ktx:+"
    

    with

    implementation "androidx.core:core-ktx:1.6.0"
    

    or

    implementation "androidx.core:core-ktx:$kotlin_version"