Flutter utilizes native build systems on Android and iOS. As these systems evolve and introduce additional features on their own pace, developers sometimes need to re-adjust the configuration to prevent build failures.
This page collects such errors and the standard procedure to work around them.
Android builds are handled by the Gradle tool, which is configured using .gradle files. Android Apps themselves are packaged, compiled & optimized by a variety of tools - all being orchestrated by the Android Gradle Plugin (AGP).
Usually, Android Studio and AGP are aligned in their versions. Android Studio also contains a few assistants to smoothen the upgrade process for existing projects.
android/build.gradle
and example/android/build.gradle
afterwards and ensure they are referring to the same AGP versionIn this example, the Gradle plugin upgrade was stopped mid-way and the build can not continue.
To fix it, open android/gradle/wrapper/gradle-wrapper.properties
(example/android/gradle/wrapper/gradle-wrapper.properties
if you develop a plugin) and replace the version in there with the required version.
With the steps above, only AGP and the wrapper got upgraded. The Kotlin compiler infrastructure is a secondary dependency which is also dependent on certain AGP/Gradle versions. To resolve it:
ext.kotlin_version = '1.2.71'
and replace it with the latest Kotlin version (or the version named in the error message).If assembleDebug
or assembleRelease
failed but no error message can be seen, you are likely on a older Flutter version (<= 1.9.1.hotfix4
) which may suppress the root cause of the error.
This problem can be solved in two ways:
beta
or dev
and restart the compilation. It may still fail, but the error will now be printed$FLUTTER_ROOT/packages/flutter_tools/gradle/flutter.gradle
file in your local installation and comment the line which reads gradle.useLogger(new FlutterEventLogger())
, then retry your build