Skip to content

[Bug] Android Build Failure: JVM target compatibility mismatch (11 vs 17) caused by fluttertoast dependency #464

@chuanming2022

Description

@chuanming2022

Hi maintainers,

I'm experiencing an Android build failure when using this library (1.4.0) in my Flutter project.

The Problem
My project fails to compile for Android with the following error:

'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.

See https://docs.gradle.org/7.5/userguide/building_java_projects.html#sec:java_jvm_compatibility for more details.
Root Cause Analysis
My Flutter project's android/app/build.gradle is configured to use Kotlin JVM target 17, which is standard for modern Android/Flutter development:

Image

// In my android/app/build.gradle
...
android {
...
kotlinOptions {
jvmTarget = "17"
}
}

After investigating the dependency tree, this build conflict appears to be caused by the fluttertoast package, which this library depends on. It seems fluttertoast (or one of its sub-dependencies) is forcing the Java compile target (compileDebugJavaWithJavac) to Java 11, which directly conflicts with my project's Kotlin target of 17.

(Optional - Only if you are sure) Unused Dependency
After a brief review of this library's source code, it also appears that fluttertoast might not be actively used anymore.

Proposed Solution
To resolve this build error for all users on modern Android configurations, could you please consider removing the fluttertoast dependency?

If the dependency is still required, perhaps it could be updated or configured to be compatible with newer JVM targets.

Thank you for your work on this great library!

My Environment
Flutter Version: 3.19.4

Library Name: razorpay_flutter

Library Version:1.4.0

fluttertoast Version (from pubspec.lock): 8.2.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions