If you are here it means that you cannot use the OSM plugin for Flutter. And if you are reading this post I hope you’re going to fix it.
This is the error:
e: /home/edoardo/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.15.0/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterInfoWindow.kt: (42, 56): Expecting an argument
e: /home/edoardo/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.15.0/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmPlugin.kt: (60, 53): Expecting an argument
e: /home/edoardo/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.15.0/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmPlugin.kt: (61, 23): Expecting an argument
e: /home/edoardo/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.15.0/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmPlugin.kt: (91, 34): Expecting an argument
........
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_osm_plugin:kaptGenerateStubsDebugKotlin'.
> Compilation error. See log for more details
* 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 27s
Exception: Gradle task assembleDebug failed with exit code 1
If you are facing the same error, you can try to fix in this way:
- invalidate cache and restart
- upgrade Flutter
- upgrade Android Studio plugins
- upgrade Kotlin version
How to invalidate cache and restart
File -> Invalidate cache/restart
How to upgrade Flutter
From the terminal type:
$ flutter upgrade
How to upgrade Android Studio Plugins
File -> Settings -> Plugins and update what the IDE is suggesting you, then restart Android Studio.
How to upgrade Kotlin version in Gradle
Under project/android/build.gradle find the buildscript{} method and update the Kotlin version like the following example:
buildscript { ext.kotlin_version = '1.4.32' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }
In particular, this last edit (line 2) made my day.
Enjoy Flutter and OSM!
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.