Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent JVM Target Compatibility: Support for Java 17 #615

Open
zinon-software opened this issue Dec 12, 2024 · 3 comments
Open

Inconsistent JVM Target Compatibility: Support for Java 17 #615

zinon-software opened this issue Dec 12, 2024 · 3 comments

Comments

@zinon-software
Copy link

Hello,

I am facing an issue while building my project that uses flutter_callkit_incoming, as my project requires Java 17 compatibility. The error is as follows:

Execution failed for task ':flutter_callkit_incoming:compileDebugKotlin'.

Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).

Steps to Reproduce:
Set the sourceCompatibility and targetCompatibility in my project to JavaVersion.VERSION_17.
Add flutter_callkit_incoming as a dependency.
Try to build the project.
Expected Behavior:
The library should support Java 17 for compatibility with modern Android projects.

Actual Behavior:
The build fails due to JVM compatibility mismatch.

Proposed Solution:
Update the build.gradle of the library to support Java 17:

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

  kotlinOptions {
      jvmTarget = "17"
  }

}

Additional Info:
Flutter version: Flutter (Channel stable, 3.27.0, on Microsoft Windows [Version 10.0.22621.4317], locale en-US)
flutter_callkit_incoming version: flutter_callkit_incoming: ^2.0.4+2
Kotlin version: (1.9.10)
Android Gradle Plugin version: (distributionUrl=https://services.gradle.org/distributions/gradle-8.9-all.zip)
I appreciate your help in resolving this issue or providing a workaround for compatibility with Java 17.

Thank you!

@RazvanTamazlicariu
Copy link

i have the same problem

@0x1af2aec8f957
Copy link

Temporary solution:

// @work/android/build.gradle

allprojects {
    ...
    subprojects {
        afterEvaluate { project ->
            if (project.plugins.hasPlugin("kotlin-android")) {
                project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
                    kotlinOptions {
                        jvmTarget = JavaVersion.VERSION_17
                        ...
                    }
                    ...
                }
                ...
            }

            if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) {
                project.android {
                    ...
                    compileOptions {
                        sourceCompatibility = JavaVersion.VERSION_17
                        targetCompatibility = JavaVersion.VERSION_17
                        ...
                    }
                }
                ...
            }
            ...
        }
        ...
    }
}
...

@Prince2347X
Copy link

Temporary solution:

// @work/android/build.gradle

allprojects {
    ...
    subprojects {
        afterEvaluate { project ->
            if (project.plugins.hasPlugin("kotlin-android")) {
                project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
                    kotlinOptions {
                        jvmTarget = JavaVersion.VERSION_17
                        ...
                    }
                    ...
                }
                ...
            }

            if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) {
                project.android {
                    ...
                    compileOptions {
                        sourceCompatibility = JavaVersion.VERSION_17
                        targetCompatibility = JavaVersion.VERSION_17
                        ...
                    }
                }
                ...
            }
            ...
        }
        ...
    }
}
...

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants