thingsboard / flutter_thingsboard_app

ThingsBoard Mobile Application
https://thingsboard.io/products/mobile/
BSD 3-Clause "New" or "Revised" License
227 stars 167 forks source link

Error (Xcode): lib/modules/dashboard/dashboard.dart:161:33: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'. #95

Closed jonaloo closed 4 months ago

jonaloo commented 5 months ago

Did anyone face this issue?

ybeshkarov commented 5 months ago

Hi @jonaloo, could you please add more details about your environment? IOS version, XCode version, Flutter version

jonaloo commented 5 months ago

Hi @ybeshkarov,

Thanks for your kind response. Let me try to give you as much information as possible, so you can help diagnose the issue that I encounter.

I checked the version using command: flutter doctor (see below):

❯ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-arm64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.4) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.3) [✓] VS Code (version 1.90.1) [✓] Connected device (5 available) [✓] Network resources

Below are the exact steps I have executed.

1) Obtain the source code: git clone https://github.com/thingsboard/flutter_thingsboard_app.git

2) flutter run --> which reported the following issue: Because every version of flutter_localizations from sdk depends on intl 0.19.0 and thingsboard_app depends on intl ^0.18.1, flutter_localizations from sdk is forbidden. So, because thingsboard_app depends on flutter_localizations from sdk, version solving failed.

3) flutter pub upgrade --major-versions --> I got the results: Changed 10 constraints in pubspec.yaml: intl: ^0.18.1 -> ^0.19.0 flutter_inappwebview: ^5.8.0 -> ^6.0.0 device_info_plus: ^9.1.1 -> ^10.1.0 geolocator: ^10.1.0 -> ^12.0.0 package_info_plus: ^5.0.1 -> ^8.0.0 form_builder_validators: ^9.1.0 -> ^10.0.1 flutter_html: 3.0.0-alpha.5 -> ^3.0.0-beta.2 firebase_core: ^2.24.2 -> ^3.1.0 firebase_messaging: ^14.7.10 -> ^15.0.1 flutter_local_notifications: ^16.3.0 -> ^17.1.2

4) I did again flutter run --> I got the results: ❯ flutter run Resolving dependencies... Downloading packages... _fe_analyzer_shared 67.0.0 (72.0.0 available) analyzer 6.4.1 (6.7.0 available) collection 1.18.0 (1.19.0 available) csslib 0.17.3 (1.0.0 available) js 0.6.7 (0.7.1 available) 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) shelf_web_socket 1.0.4 (2.0.0 available) test 1.25.2 (1.25.7 available) test_api 0.7.0 (0.7.2 available) test_core 0.6.0 (0.6.4 available) uni_links 0.5.1 (discontinued replaced by app_links) vm_service 14.2.1 (14.2.4 available) web_socket_channel 2.4.5 (3.0.0 available) Got dependencies! 1 package is discontinued. 15 packages have newer versions incompatible with dependency constraints. Try flutter pub outdated for more information. Launching lib/main.dart on iPhone SE (3rd generation) in debug mode... Updating project for Xcode compatibility. Upgrading project.pbxproj Upgrading Runner.xcscheme Running pod install... 569ms ..... Resolving dependencies of Podfile CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: Specs/0/3/5/Firebase/10.27.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: all_pods_versions_6_8_6.txt exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: Specs/6/8/6/OrderedSet/6.0.3/OrderedSet.podspec.json exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: all_pods_versions_4_2_c.txt exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: Specs/4/2/c/FlutterMacOS/3.16.0/FlutterMacOS.podspec.json exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: all_pods_versions_0_2_a.txt exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: Specs/0/2/a/MTBBarcodeScanner/5.0.11/MTBBarcodeScanner.podspec.json exists! Returning local because checking is only performed in repo update CDN: trunk Relative path: Specs/0/3/5/Firebase/10.27.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update [!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly": In snapshot (Podfile.lock): Firebase/CoreOnly (= 10.18.0)

  In Podfile:
    firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 3.1.0, which depends on
      Firebase/CoreOnly (= 10.27.0)

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/CoreOnly` inside your development pod `firebase_core`.
   You should run `pod update Firebase/CoreOnly` to apply changes you've made.

/opt/homebrew/lib/ruby/gems/3.3.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:317:in `raise_error_unless_state'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict'
<internal:kernel>:90:in `tap'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `unwind_for_conflict'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:257:in `process_topmost_state'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:94:in `resolve'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1082:in `block in resolve_dependencies'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1080:in `resolve_dependencies'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:125:in `analyze'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:422:in `analyze'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:162:in `install!'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/lib/ruby/gems/3.3.0/gems/cocoapods-1.15.2/bin/pod:55:in `<main>'

Error output from CocoaPods: ↳ [!] Automatically assigning platform iOS with version 12.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies. To update the CocoaPods specs, run: pod repo update

5) I did the following commands: cd ios pod install --repo-update pod update Firebase/CoreOnly cd .. flutter run

I got the following results: Launching lib/main.dart on iPhone SE (3rd generation) in debug mode... Running pod install... 1,340ms Running Xcode build... Xcode build done. 23.3s Failed to build iOS app Error (Xcode): lib/modules/dashboard/dashboard.dart:161:33: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'. Could not build the application for the simulator. Error launching application on iPhone SE (3rd generation).

Hope to hear from you soon. Many thanks.

salemaljebaly commented 5 months ago

Hello @jonaloo To resolve this, you can switch to Flutter 3.19, which has been tested and confirmed to work well with the current setup. You can switch the Flutter version using fvm (Flutter Version Manager) or by manually downloading and setting up Flutter 3.19.

salemaljebaly commented 5 months ago

@jonaloo,

Please check this PR: https://github.com/salemaljebaly/flutter_thingsboard_app/pull/1.

I have upgraded the packages and fixed the Uri and Pods bugs. The application now supports Flutter 3.22.1. The application works well, but we need to test all the functionality thoroughly before opening a PR on the main ThingsBoard app repository.

jonaloo commented 5 months ago

@salemaljebaly I wish to inform that I switched to Flutter 3.19 as you suggested, it work perfectly. I successfully reproduced the app!!!! I will try out the Flutter 3.22.1 with your fixed.

safelineprojects commented 5 months ago

Hi @jonaloo - how did you solve this issue, I'm on Flutter 3.22.2 and facing the same issue related to Uri. I'm a novice and would appreciate it if you could explain in detail.

jonaloo commented 5 months ago

hi @safelineprojects

I followed the suggestion by @salemaljebaly to change from the Flutter 3.22.2 to Flutter 3.19; this is where I chose the stable version of 3.19.6, which can be found here:

https://docs.flutter.dev/release/archive?tab=macos

or

(Note that I am on MAC OS) https://mirrors.cloud.tencent.com/flutter/flutter_infra/releases/stable/macos/flutter_macos_3.19.6-stable.zip

This is how I done it, simply delete the existing Flutter version and replace it with version 3.19.6.

Pleaes note @salemaljebaly has provided a fixed version by changing the Uri to Webri which can be found here below link. (I haven't try this yet) https://github.com/salemaljebaly/flutter_thingsboard_app/pull/1

Hope the above help you.

gaurav36 commented 4 months ago

I am also facing issue with flutter version 3.22.2 , is there anyway if you can solve this issue without downgrading flutter to 3.19.6 ? I am also facing dependency issue while downgrading. It would be really nice if developer can fix this small issue.

I have following error log:


Running Gradle task 'assembleDebug'...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply

You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply

lib/modules/dashboard/dashboard.dart:157:33: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
              targetOrigin: Uri.parse('*'));
                                ^
lib/modules/dashboard/dashboard.dart:222:66: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
          .postWebMessage(message: webMessage, targetOrigin: Uri.parse('*'));
                                                                 ^
lib/modules/dashboard/dashboard.dart:231:48: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
        message: webMessage, targetOrigin: Uri.parse('*'));
                                               ^
lib/modules/dashboard/dashboard.dart:296:60: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
                        initialUrlRequest: URLRequest(url: _initialUrl),
                                                           ^
lib/utils/ui/tb_recaptcha.dart:75:48: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
            initialUrlRequest: URLRequest(url: _initialUrl),
                                               ^
lib/utils/ui/tb_recaptcha.dart:123:27: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
        targetOrigin: Uri.parse('*'));
                          ^
lib/modules/url/url_page.dart:37:26: Error: The argument type 'Uri' can't be assigned to the parameter type 'WebUri?'.
 - 'Uri' is from 'dart:core'.
 - 'WebUri' is from 'package:flutter_inappwebview_platform_interface/src/web_uri.dart' ('../../../.pub-cache/hosted/pub.dev/flutter_inappwebview_platform_interface-1.0.10/lib/src/web_uri.dart').
                url: Uri.parse(url),
                         ^
lib/core/auth/signup/terms_of_use.dart:52:27: Error: No named parameter with the name 'tagsList'.
                          tagsList: [],
                          ^^^^^^^^
../../../.pub-cache/hosted/pub.dev/flutter_html-3.0.0-beta.2/lib/flutter_html.dart:66:3: Context: Found this candidate, but the arguments don't match.
  Html.fromDom({
  ^^^^^^^^^^^^
lib/core/auth/signup/privacy_policy.dart:52:27: Error: No named parameter with the name 'tagsList'.
                          tagsList: [],
                          ^^^^^^^^
../../../.pub-cache/hosted/pub.dev/flutter_html-3.0.0-beta.2/lib/flutter_html.dart:66:3: Context: Found this candidate, but the arguments don't match.
  Html.fromDom({
  ^^^^^^^^^^^^
Target kernel_snapshot failed: Exception

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/usr/bin/flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy' line: 1629

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/usr/bin/flutter/bin/flutter'' finished with non-zero exit value 1

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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 28s
Error: Gradle task assembleDebug failed with exit code 1
salemaljebaly commented 4 months ago

Yes @gaurav36, I already working on that you can use this PR https://github.com/thingsboard/flutter_thingsboard_app/pull/97

ybeshkarov commented 4 months ago

Hello all,

The Flutter version 3.19.6 is currently officially supported. So I recommend using this version so far, or you can use https://fvm.app