wasabeef / flutter_ua_client_hints

Provide User-Agent Client Hints to a Flutter app.
MIT License
44 stars 20 forks source link

Unable to build fresh Flutter 3.22 project after adding ua_client_hints 1.3.1 #115

Open kendas opened 3 months ago

kendas commented 3 months ago

Hi.

I had an issue building a Flutter project for Android where this library is a transitive dependency. After investigating a few leads, I discovered that this project does not build with the default generated Flutter app.

I created a new Flutter project like so:

flutter create new_android
Creating project new_android...
Resolving dependencies in `new_android`...
Downloading packages...
Got dependencies in `new_android`.
Wrote 129 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev

In order to run your application, type:

  $ cd new_android
  $ flutter run

Your application code is in new_android/lib/main.dart.

I then ran the default app from Android Studio on my phone. Works.

Then I added this library:

flutter pub add ua_client_hints
Resolving dependencies... 
Downloading packages... 
  collection 1.18.0 (1.19.0 available)
  flutter_lints 3.0.2 (4.0.0 available)
  leak_tracker 10.0.4 (10.0.5 available)
  leak_tracker_flutter_testing 3.0.3 (3.0.5 available)
  lints 3.0.0 (4.0.0 available)
  material_color_utilities 0.8.0 (0.12.0 available)
  meta 1.12.0 (1.15.0 available)
  string_scanner 1.2.0 (1.3.0 available)
  test_api 0.7.0 (0.7.3 available)
+ ua_client_hints 1.3.1
  vm_service 14.2.1 (14.2.4 available)
Changed 1 dependency!
10 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

At this point I attempted to run the app again, and this is the output I got:

Resolving dependencies...
Downloading packages...
  collection 1.18.0 (1.19.0 available)
  flutter_lints 3.0.2 (4.0.0 available)
  leak_tracker 10.0.4 (10.0.5 available)
  leak_tracker_flutter_testing 3.0.3 (3.0.5 available)
  lints 3.0.0 (4.0.0 available)
  material_color_utilities 0.8.0 (0.12.0 available)
  meta 1.12.0 (1.15.0 available)
  string_scanner 1.2.0 (1.3.0 available)
  test_api 0.7.0 (0.7.3 available)
  vm_service 14.2.1 (14.2.4 available)
Got dependencies!
10 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Launching lib/main.dart on ASUS AI2202 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/kaarel/.pub-cache/hosted/pub.dev/ua_client_hints-1.3.1/android/build.gradle' line: 46

* What went wrong:
A problem occurred evaluating project ':ua_client_hints'.
> Could not find method jvmToolchain() for arguments [17] on extension 'kotlin' of type org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension.

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

Further information on the Flutter version:

flutter --version
Flutter 3.22.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b0850beeb2 (8 days ago) • 2024-07-16 21:43:41 -0700
Engine • revision 235db911ba
Tools • Dart 3.4.4 • DevTools 2.34.3

Is there any changes I can make to my gradle settings that would resolve this?

T-eli commented 3 months ago

change kotlin.android plugin version to 1.9.10 or newer in settings.gradle (or build.gradle buildscript) :

plugins {
    ...
    id "org.jetbrains.kotlin.android" version "1.9.10" apply false //change from 1.7.10
}

you should also run flutter upgrade so that future projects template will have the new plugin version.