androidkotlincallkittrtc.io

How to Resolve NoClassDefFoundError for EnumEntriesKt After Upgrading CallKit and TRTC UI to Version 2.9?


After upgrading my CallKit project to use the new rtc-engine and version 2.9 of the TRTC UI, I encountered the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/enums/EnumEntriesKt;

From my research, this error seems to be related to the Kotlin version being too low. Specifically, it appears that the new TRTC UI requires Kotlin version 1.8.20 or higher. Currently, my project is using an older version of Kotlin, which might be causing this issue.

What is the recommended way to resolve this error? Should I upgrade the Kotlin version globally in my project, or is there a specific configuration I need to apply? Additionally, are there any potential compatibility issues I should be aware of when upgrading Kotlin, especially since some libraries in my project might also depend on specific Kotlin versions?


Solution

  • The NoClassDefFoundError for EnumEntriesKt occurs because the new TRTC UI version 2.9 requires Kotlin version 1.8.20 or higher. To resolve this issue, you have two options:

    Solution 1: Upgrade Kotlin Plugin Version (Recommended)

    Update the Kotlin plugin version in your project’s root build.gradle file to at least 1.8.20 (or higher, such as 1.9.0). This will ensure that the kotlin-stdlib dependency is also updated to a compatible version.

    Update the Kotlin plugin version in your project’s root

    1. Open your root build.gradle file and update the Kotlin plugin version:

      buildscript {
          dependencies {
              classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
          }
      }
      
    2. Apply the Kotlin plugin in your app’s build.gradle file:

      apply plugin: 'org.jetbrains.kotlin.android'
      

    This approach ensures that the correct Kotlin version is used throughout your project.

    Solution 2: Manually Specify Kotlin Version

    If you prefer to manually specify the Kotlin version, you can add the following dependency to your app’s build.gradle file:

    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
    

    However, be cautious with this approach, as other libraries in your project might depend on specific Kotlin versions, which could lead to compatibility issues. If you encounter conflicts, you may need to align all dependencies to use the same Kotlin version.

    Recommendation

    The first solution (upgrading the Kotlin plugin version) is recommended because it ensures consistency across your project and avoids potential conflicts with other libraries. After making these changes, rebuild your project, and the NoClassDefFoundError should be resolved.