skip to Main Content

recently I upgrade my flutter to 2.9.0-0.1.pre and dart to 2.16.0 but there is problem and the problem: I can create and run new projects but my old flutter project cant build and show these errors! also i create new project and move old project files to new one but errors still there
errors:

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/06445d7ee3d674db365da5b7e383aeec/jetified-window-1.0.0-beta04-api.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/185d46b6321985f52dcc07c04b9e0199/jetified-kotlin-stdlib-common-1.5.31.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/57fff25d753f492b2e9dfa8a7a25a127/jetified-kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/989d7c521cad3a1e2e82ee6a7a836f54/jetified-kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/9c675fcd73ec0913dfa5836b73d5959f/jetified-window-java-1.0.0-beta04-api.jar!/META-INF/window-java_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/cdd51607f1d98bcc689bce197d763afe/jetified-kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.gradle/caches/transforms-2/files-2.1/ced2a85cd1d4e10ca7b42bb11579f9f7/jetified-kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/Wakelock.kt: (23, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/Wakelock.kt: (24, 37): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/Wakelock.kt: (26, 23): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/Wakelock.kt: (36, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (16, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (17, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (21, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (22, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (26, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (30, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (34, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (38, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: /Users/systemName/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.6/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt: (42, 16): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from /Users/systemName/.gradle/caches/transforms-2/files-2.1/7ed1fc227d449123990dfe95b91bbf13/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':wakelock:compileDebugKotlin'.
> Compilation error. See log for more details

* 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 15s
[!] Your project requires a newer version of the Kotlin Gradle plugin.
    Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update /Users/systemName/AndroidStudioProjects/projectname/android/build.gradle:
    ext.kotlin_version = '<latest-version>'
Exception: Gradle task assembleDebug failed with exit code 1

and my build.gradle file is :

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
//        applicationId "ri.mozayedekhodro.mozayedekhodro"
        applicationId "vestasystem.ir.mozayede"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

so how can i fix this bug for android?
web and ios can run but android getting failed

3

Answers


  1. You need to upgrade Kotlin to version 1.5.1 but for the Flutter 2.9.1 best version is 1.5.31. Look here.

        buildscript {
    -    ext.kotlin_version = '1.1.15'
    +    ext.kotlin_version = '1.5.1'
    
    Login or Signup to reply.
  2. you have 2 ways to solved this problem, first:

    Clicking on Gradle (on the right side bar) ->
    Then under :app
    Then choose assembleDebug (or assembleYourFlavor if you use flavors)
    

    or its because of your network:
    network blocked non secured http download request. I changed my network and the gradle build completed itself.

    Login or Signup to reply.
  3. https://docs.flutter.dev/release/breaking-changes/kotlin-version
    According to this you need to update kotlin version to 1.5.31 inside <app-src>/android/build.gradle

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search