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

JVM target inconsistency #830

Open
Schefferbird opened this issue May 9, 2024 · 8 comments
Open

JVM target inconsistency #830

Schefferbird opened this issue May 9, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Schefferbird
Copy link

Flutter Version

My version : 3.19.6

Lib Version

My version : master

Platform (Android / iOS / web) + version

Platform : Android 34

Describe the bug

When upgraded to gradle 8.3 and targetSdk 34 to follow along with the rest of the community I'm getting the following error when running Flutter run:
Execution failed for task ':assets_audio_player_web:compileDebugKotlin'.

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

It is a bit absurd that this stops my flutter run. Gradle is a mess combined with Java/Kotlin jungle.

Small code to reproduce

compileOptions {
        // Flag to enable support for the new language APIs
        //coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 17
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'

    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    

    defaultConfig {
        buildToolsVersion "35-rc2"
        applicationId "com.xxx.xxx"
        minSdk 23
        targetSdk flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        if (publish) {
            ndk {
                debugSymbolLevel 'SYMBOL_TABLE'
            }
            resConfigs "en","sv","it","ar","de","es","fr","no","pl","ru","uk","sr"
        }
    }
@Schefferbird Schefferbird added the bug Something isn't working label May 9, 2024
@mayouf
Copy link

mayouf commented Jun 27, 2024

The same as me:

Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':assets_audio_player:compileDebugKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).

  Consider using JVM Toolchain: https://kotl.in/gradle/jvm/toolchain
  Learn more about JVM-target validation: https://kotl.in/gradle/jvm/target-validation 

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 52s
Error: Gradle task assembleDebug failed with exit code 1

Here is my gradle :

android {
    namespace 'com.xxx.xxxx'


    compileSdkVersion 34

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }


    defaultConfig {
        applicationId "com.xxx.xxx"
        minSdkVersion 26
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }



    packagingOptions {
        jniLibs {
            useLegacyPackaging = true
        }
    }

}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.20"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0'
    implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
    implementation("com.google.firebase:firebase-crashlytics-ndk")
    implementation("com.google.firebase:firebase-analytics")
}

@mayouf
Copy link

mayouf commented Jun 27, 2024

@Schefferbird did you find the solution ?

@dllzar
Copy link

dllzar commented Aug 13, 2024

Same here 🙌

@KirbyRedius
Copy link

Same

@Schefferbird
Copy link
Author

Schefferbird commented Aug 19, 2024

@dllzar @KirbyRedius @mayouf first solved it by changing it locally which works, but it is not a long-term solution. In the end, I switched to just_audio which has more frequent updates. But if you need to keep it for some reason find your hidden folder pub-cache / hosted / pub.dev / assets_audio_player 3.1.1 and find the build.gradle file and make the correction:

compileOptions {
    // Sets Java compatibility to Java 17
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
    jvmTarget = '17'
}

@KirbyRedius
Copy link

@Schefferbird thank you, that's really helpful! 😊

@gavnyx
Copy link

gavnyx commented Oct 2, 2024

#846

@wangya123456789
Copy link

Try this method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants