Open ianthetechie opened 3 weeks ago
Thank you for this bug report @ianthetechie.
The problem your build fails is that you need to set the used kotlin version to be at least 1.9.0.
In android/settings.gradle
update the kotlin version like so:
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
After that your build should succeed because you're using flutter v3.22, the latest version. (If not, run flutter clean
and give it another try.)
If users try to build the app with an earlier flutter version, the build might fail, too. Because flutter changed it's minimum supported android version to android 5 (SDK version 21) just recently with flutter 3.22. When using an older flutter version (we currently support down to flutter 3.10), the user has to manually set the minSdk version in android/app/build.gradle
like so:
defaultConfig {
minSdk = 21 // previously flutter.minSdkVersion
}
Alternativly, you can adjust the minimum flutter version in your example app here:
Let me know if these steps help, then I can update the docs with it. (:
Why do we require Kotlin 1.9.0+
- didn't see this before.
@kuhnroyal It got increased in https://github.com/maplibre/flutter-maplibre-gl/pull/270 about a year ago. Do you think it's possible to lower the kotlin version?
Some research:
A new created flutter project uses kotlin 1.7.10 by default. The newest version of kotlin is currently 2.0.0.
Oof. I think you're right. Will test when I'm back at my computer. I feel pretty stupid 😅
But uh seriously I'm actually shocked that 1) the Android templates for Flutter are this out of date, and 2) that there aren't any lints or other ways of detecting this situation. It seems like it would be fairly common since my impression is that language and tooling updates take a LOT longer in the JVM ecosystem. In swift we assume you're using latest or maybe -1 release. As you say this is fixable with docs / FAQ.
That was indeed the fix. Thanks a bunch for the quick + detailed reply @josxha!
I guess we should just update the docs.
Platforms
android
Version of flutter maplibre_gl
0.20
Bug Description
I've been having some issues getting Android builds to work after upgrading (from a rather old release on the m0nac0 repo). The deprecation errors and renames were easy to fix. Everything works on iOS, but I still can't get the simple demo project to build for Android.
The project is essentially a reproduction of the MapLibre cluster demo with earthquake data.
Steps to Reproduce
Option 1: Check out this repo and try to run on Android (emulator in my case). NOTE: Check out the
upgrade-to-0.20
branch!Option 2: Create a new flutter project targeting iOS and Android. Then copy/replace the following files with the versions from my repo:
Expected Results
It runs like on iOS.
Actual Results
Build failures. Usually the first build after clean (and nuking
$HOME/.pub-cache/hosted/pub.dev/
and$HOME/.gradle/caches/
yields the following:Gradle being gradle, trying to run a second time never yields the same failure as the first run (wtf?). It usually fails like this:
For reference, here is my flutter doctor output:
Code Sample
See repo and steps to reproduce above.