记录一次报错,关于项目升级到2.5.0之后报错问题
错误信息一:
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.
解决办法:
在您的项目级 gradle 文件中,只需将 ext.kotlin.version 从您拥有的任何版本增加到“1.4.32”或任何可用的最新版本。 路径:/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
}
错误信息二:
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.
解决办法
:
路径:/android/app/build.gradle
,将minSdkVersion 的版本改为大一些的,比如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
}