I found many discussions regarding this error, but I am not able to fix it.
I have a flutter project, building to Android and iOS. I just upgraded from 3.7.10 to 3.19.0 and are upgrading the pubspec libraries:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
flutter_svg: ^2.0.10+1
provider: ^6.0.5
qr_flutter: ^4.1.0
polygon: ^0.1.0
http: ^1.1.0
shared_preferences: ^2.2.1
url_launcher: ^6.1.14
intl: ^0.18.1
collection: ^1.17.2
add_2_calendar: ^3.0.1
text_scroll: ^0.2.0
ory_client: ^1.2.11
webview_flutter: ^4.7.0
get_it: ^7.6.7
injectable: ^2.3.2
dio: ^5.3.3
one_of: ^1.5.0
flutter_web_auth: ^0.5.0
flutter_libphonenumber: ^2.1.5
flutter_widget_from_html: ^0.14.11
dev_dependencies:
flutter_test:
sdk: flutter
injectable_generator: ^2.4.1
build_runner: ^2.4.6
flutter_lints: ^3.0.1
The build.gradle:
buildscript {
ext.kotlin_version = '1.7.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
When I try to run or build the project I get the following error:
* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':wakelock' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50
* 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 2s
Error: Gradle task assembleDebug failed with exit code 1
I suppose the problem relies in the iOS dependency wakelock, but if I take a look at its gradle I find ext.kotlin_version = '1.6.10'
If in Android Studio I do CTRL + SHIFT + F
and look for all ext.kotlin_version
s, all are greater than 1.3.50.
I have already done flutter clean
and flutter pub get
.
This did not help, this neither.
What's wrong?
The problem wos that wakelock
was included as a dipendency because of another library present in the pubspec.yaml
, the min requirement was a very old version which run with an old gradle version. In order to fix the problem I needed to add a newer version, even if I dont use it directly. Adding wakelock: ^0.6.2
fixed my problem.