Tag Archives: Project Upgrade to flutter2.5.0 Error

How to Solve Project Upgrade to flutter2.5.0 Error

Record an error report about the error report after the project is upgraded to 2.5.0

error message 1:

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.

Solution:
in your project level gradle file, just increase ext.kotlin.version from any version you have to "1.4.32" or any latest version available. Path:/Android/build. Gradle

buildscript {
    // ext.kotlin_version = '1.3.50'
    ext.kotlin_version = '1.4.32'
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google'}
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}
        // google()
        // mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google'}
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}
        // google()
        // mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Error Message 2:
D8: Cannot fit requested classes in a single dex file (# methods: 76688 > 65536) com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The shrinker may have failed to optimize the Java bytecode.
Solution
Path: /android/app/build.gradle,Change the minSdkVersion version to a larger one, e.g. 21

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.good_commodity"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }