Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Strange errors after upgrading a few versions #456

Open
ianthetechie opened this issue Jun 8, 2024 · 7 comments
Open

[BUG] Strange errors after upgrading a few versions #456

ianthetechie opened this issue Jun 8, 2024 · 7 comments
Labels
android bug Something isn't working documentation Improvements or additions to documentation example Affects the example app
Milestone

Comments

@ianthetechie
Copy link

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:

Resolving dependencies...
Downloading packages...
  leak_tracker 10.0.4 (10.0.5 available)
  leak_tracker_flutter_testing 3.0.3 (3.0.5 available)
  material_color_utilities 0.8.0 (0.12.0 available)
  meta 1.12.0 (1.15.0 available)
  test_api 0.7.0 (0.7.2 available)
  vm_service 14.2.1 (14.2.3 available)
Got dependencies!
6 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Launching lib/main.dart on sdk gphone arm64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > /Users/ianthetechie/.gradle/caches/transforms-3/02b67353dd8b31f361ea7c001ecdb116/transformed/jetified-android-plugin-annotation-v9-3.0.0/META-INF/com/android/build/gradle/aar-metadata.properties (No such file or directory)

* 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 5s
Error: Gradle task assembleDebug failed with exit code 1

Gradle being gradle, trying to run a second time never yields the same failure as the first run (wtf?). It usually fails like this:

Launching lib/main.dart on sdk gphone arm64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: /Users/ianthetechie/.gradle/caches/transforms-3/02b67353dd8b31f361ea7c001ecdb116/transformed/jetified-android-plugin-annotation-v9-3.0.0/AndroidManifest.xml (No such file or directory)

* 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
Retrying Gradle Build: #1, wait time: 100ms
[!] Gradle threw an error while downloading artifacts from the network.
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: /Users/ianthetechie/.gradle/caches/transforms-3/02b67353dd8b31f361ea7c001ecdb116/transformed/jetified-android-plugin-annotation-v9-3.0.0/AndroidManifest.xml (No such file or directory)

* 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 909ms
[!] Gradle threw an error while downloading artifacts from the network.
Error: Gradle task assembleDebug failed with exit code 1

For reference, here is my flutter doctor output:

flutter doctor -v
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale
    en-US)
    • Flutter version 3.22.2 on channel stable at /Users/ianthetechie/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (2 days ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/ianthetechie/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/ianthetechie/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/ianthetechie/Library/Android/sdk
    • Java binary at: /Users/ianthetechie/Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Users/ianthetechie/Applications/Android
      Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.2)
    • IntelliJ at /Users/ianthetechie/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 80.0.2
    • Dart plugin version 241.17502

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (5 available)
    • sdk gphone arm64 (mobile)       • emulator-5554                        •
      android-arm64  • Android 11 (API 30) (emulator)
    • iPhone 15 (mobile)              • 1A18292A-B71D-4D98-842F-F1BA9EB9886B •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                •
      darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                •
      darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                               •
      web-javascript • Google Chrome 125.0.6422.112
    ! Error: Browsing on the local area network for 대박. Ensure the device is
      unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)
    ! Error: Browsing on the local area network for 冬子. Ensure the device is
      unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Code Sample

See repo and steps to reproduce above.

@ianthetechie ianthetechie added the bug Something isn't working label Jun 8, 2024
@josxha
Copy link
Collaborator

josxha commented Jun 8, 2024

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. (:

@josxha josxha added documentation Improvements or additions to documentation android example Affects the example app labels Jun 8, 2024
@kuhnroyal
Copy link
Collaborator

Why do we require Kotlin 1.9.0+ - didn't see this before.

@josxha
Copy link
Collaborator

josxha commented Jun 8, 2024

@kuhnroyal It got increased in #270 about a year ago. Do you think it's possible to lower the kotlin version?

@josxha
Copy link
Collaborator

josxha commented Jun 8, 2024

Some research:

A new created flutter project uses kotlin 1.7.10 by default.
The newest version of kotlin is currently 2.0.0.

@josxha josxha added this to the v0.20.1 milestone Jun 8, 2024
@ianthetechie
Copy link
Author

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.

@ianthetechie
Copy link
Author

That was indeed the fix. Thanks a bunch for the quick + detailed reply @josxha!

@kuhnroyal
Copy link
Collaborator

I guess we should just update the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working documentation Improvements or additions to documentation example Affects the example app
Projects
None yet
Development

No branches or pull requests

3 participants