I am getting the following errors when running flutter build apk
in Windows (using VSCode)
The binary version of its metadata is 1.8.0, expected version is 1.6.0.
However, in my build.gradle, I have:
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
}
}
Really confused! Why is it not using Kotlin 1.7.10 (error suggests it's using 1.6.0?) and why is it then trying to use libraries that require 1.8.0?
EDIT:
I should have said that I did try the obvious top question related to this on Stack before asking this question:
And I did try the top-rated (non-accepted) answer to this:
https://stackoverflow.com/a/74425347/187030
But this has not solved the problem for me.
I would also say this used to work (I have all the prerequisites installed from here, and flutter doctor
is all green ticks)
I am probably doing something really n00by here as I'm a Windows .Net developer and I appreciate Flutter is wrapping a toolchain that I am not at all familiar with... but I'd really like to understand why I'm getting this problem and how to diagnose a solution for it....
Also, worth saying it does create the APK despite the errors, and, weirdly, if I build the apk with debug, then I don't get these errors:
flutter build apk
<-- builds with errors ❌
flutter build apk --debug
<-- builds without errors ✅
flutter build appbundle
<-- builds without errors ✅