QuisApp / flutter_contacts

MIT License
83 stars 138 forks source link

Build failed after Gradle 8.0.2 upgrade (on 1.1.7) #130

Closed TiffApps closed 1 year ago

TiffApps commented 1 year ago

Hello, I'm getting this error:

[        ] FAILURE: Build failed with an exception.
[        ] * What went wrong:
[        ] Execution failed for task ':flutter_contacts:compileDebugKotlin'.
[        ] > 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
[        ]   Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[        ] > Run with --scan to get full insights.
[        ] * Exception is:
[        ] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':flutter_contacts:compileDebugKotlin'.

that I can fix it by adding

// ...

android {
    namespace 'co.quis.flutter_contacts'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    // ...
}

// ...

to my ...\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_contacts-1.1.7\android\build.gradle but it shouldn't require this normally, all the other packages are fine so it suggests Gradle configuration isn't well done in this package. It's also obviously bad to manually modify the cached packages.

For starters, the namespace should be defined like this for backward compatibility (this fixes another potential issue, not the current one) :

// ...

android {

    // Conditional for compatibility with AGP <4.2.
    if (project.android.hasProperty("namespace")) {
        namespace 'co.quis.flutter_contacts'
    }

    // ...
}

// ...

cc: @joachimvalente

joachim-quis commented 1 year ago

Thanks for reporting @TiffApps Closing as duplicate of #127