PhilipsHue / flutter_reactive_ble

Flutter library that handles BLE operations for multiple devices.
https://developers.meethue.com/
Other
661 stars 321 forks source link

'readRssi' Method Not Defined for 'ReactiveBlePlatform' #835

Closed DeToxer closed 6 months ago

DeToxer commented 7 months ago

Describe the bug After upgrading the flutter_reactive_ble library from version 5.2.0 to 5.3.0, the app fails to compile on both Android and iOS platforms. The compiler error indicates that the method readRssi isn't defined for the class ReactiveBlePlatform. This issue has been tested and confirmed on two devices: an iPhone simulator (iOS version 17.0, iPhone 15 Pro Max) and an Android emulator (Pixel 7 Pro API 33). The problem persists despite attempts to clean the build environment using flutter cleanand flutter pub cache clean --force. Notably, this issue does not arise in a newly created Flutter project.

Smartphone / tablet Device: iPhone 15 Pro Max/Pixel 7 Pro OS: iOS 17.0/Android 12 (SDK 33) Package version: flutter_reactive_ble 5.3.0

Additional context The issue appears to be specifically associated with version 5.3.0 of the flutter_reactive_ble library. Reverting to version 5.2.0 or initiating a new Flutter project does not result in this compile-time error, suggesting that the problem is isolated to this particular version update.

Android stack trace:

- 'ReactiveBlePlatform' is from 'package:reactive_ble_platform_interface/src/reactive_ble_platform_interface.dart' ('../../../../../.pub-cache/hosted/pub.dev/reactive_ble_platform_interface-5.2.0/lib/src/reactive_ble_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'readRssi'.
      _blePlatform.readRssi(deviceId);
                   ^^^^^^^^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

iOS stack tace:

Error (Xcode): ../../../../../.pub-cache/hosted/pub.dev/flutter_reactive_ble-5.3.0/lib/src/reactive_ble.dart:405:20: Error: The method 'readRssi' isn't defined for the class 'ReactiveBlePlatform'.

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

Flutter doctor -v output log

[✓] Flutter (Channel stable, 3.16.9, on macOS 14.1.1 23B81 darwin-arm64, locale nb-NO)
    • Flutter version 3.16.9 on channel stable at /Users/detoxer/dev/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (17 hours ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/detoxer/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/detoxer/dev/ide/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2023.1)
    • Android Studio at /Users/detoxer/dev/ide/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.7+0-17.0.7b1000.6-10550314)

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

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 13 (API 33) (emulator)
    • iPhone 15 Pro Max (mobile)  • 9F5A3771-9354-4FB6-883B-0EA1A03D2C30 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.1.1 23B81 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 121.0.6167.85
    ! Error: Browsing on the local area network for iPhone (2). 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!
farr64 commented 7 months ago

I ran into the same problem. My solution was to force this in pubspec.yaml without the "^"

flutter_reactive_ble: 5.2.0

Up tp now, I had it as "^5.2.0" with the "^" (which allowed never versions, such as the ill-fated 5.3.0).

Now, 5.3.0 is not allowed and things continue to work perfectly with 5.2.0.

Then, I deleted this directory:

~/.pub-cache/hosted/pub.dev/flutter_reactive_ble-5.3.0/

farr64 commented 7 months ago

I'm sure the good folks in charge of this wonderful package will come up with 5.3.1 ASAP.

Thanks!

ffamar commented 7 months ago

I have the same issue.

farr64 commented 7 months ago

I'm afraid everyone who goes from 5.2.0 to 5.3.0 will have the same issue. See my solution above: Stay on 5.2.0 and disallow 5.3.0.

Of course, as soon as 5.3.1 (or whatever) is released, change your pubspec.yaml to whatever will be applicable then. For instance:

flutter_reactive_ble: ^5.3.1

DeToxer commented 7 months ago

I see that the pubspec.yaml inside flutter_reactive_ble and reactive_ble_mobile still targets reactive_ble_platform_interface: ^5.2.0and reactive_ble_mobile: ^5.2.0 instead of 5.3.0. That might be the issue.

Edit: I also see that the lock files are checked in where the dependencies (reactive_ble_mobile and reactive_ble_platform_interface) are pinned to 5.2.0

Taym95 commented 6 months ago

my bad will fix it and make realese soon