objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
927 stars 115 forks source link

bug: unsupported operation: Loaded ObjectBox core dynamic library has unsupported version 0.13.0, expected ^0.14.0 #309

Closed yeikel16 closed 2 years ago

yeikel16 commented 2 years ago

Additionally, you can choose to provide more details, e.g. the output of:

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at E:\Programas\SDK • Platform android-30, build-tools 30.0.2 • ANDROID_SDK_ROOT = E:\Programas\SDK • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.0) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.9.31025.194 • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • 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 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.60.0) • VS Code at C:\Users\Yeikel\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.26.0

[√] Connected device (4 available) • Redmi Note 7 (mobile) • d97ede0d • android-arm64 • Android 10 (API 29) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versión 10.0.19043.1165] • Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131 • Edge (web) • edge • web-javascript • Microsoft Edge 93.0.961.38


### Steps to reproduce
I'm creating a unit test for a method that returns a `Stream<List<Card>>` and the test fails in all the ways I tried.

### Code
```dart
  Stream<List<Card>> getAllCardsStream() {
    final _stream = _cardsBox
        .query()
        .watch(triggerImmediately: true)
        .map((query) => query.find());

    return _stream;
  }

Test:

test('should return a [Stream<List<Card>>]', () async {
      final result = <List<Card>>[];
      final box = testEnv.box;

      cardsDataBase.getAllCardsStream().listen(result.add);

      box.put(tCardModel);

      await yieldExecution();

      expect(result, [
        [tCardModel],
      ]);
    });

If applicable, add code to help explain your problem.

environment: sdk: ">=2.13.0 <3.0.0"

dependencies: flutter: sdk: flutter equatable: ^2.0.3 objectbox: ^1.2.0 objectbox_flutter_libs: any

dev_dependencies: build_runner: any objectbox_generator: any test: ^1.17.0 mocktail: ^0.1.4 very_good_analysis: ^2.3.0

- Include affected entity classes.
```dart
import 'package:objectbox/objectbox.dart';

/// [Card] model for database
@Entity()
class Card {
  ///
  Card({
    required this.bankName,
    required this.cardNumber,
    required this.ownersName,
    required this.phoneNumber,
    required this.expDate,
    required this.moneyType,
  });

  ///
  int id = 0;

  /// Bank name
  final String bankName;

  /// Card number
  final String cardNumber;

  /// Owners name
  final String ownersName;

  /// Phone number
  final String phoneNumber;

  /// Expire date
  final String expDate;

  /// Money type
  final String moneyType;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is Card &&
        other.bankName == bankName &&
        other.cardNumber == cardNumber &&
        other.ownersName == ownersName &&
        other.phoneNumber == phoneNumber &&
        other.expDate == expDate &&
        other.moneyType == moneyType;
  }

  @override
  int get hashCode {
    return bankName.hashCode ^
        cardNumber.hashCode ^
        ownersName.hashCode ^
        phoneNumber.hashCode ^
        expDate.hashCode ^
        moneyType.hashCode;
  }

  Card copyWith({
    String? bankName,
    String? cardNumber,
    String? ownersName,
    String? phoneNumber,
    String? expDate,
    String? moneyType,
  }) {
    return Card(
      bankName: bankName ?? this.bankName,
      cardNumber: cardNumber ?? this.cardNumber,
      ownersName: ownersName ?? this.ownersName,
      phoneNumber: phoneNumber ?? this.phoneNumber,
      expDate: expDate ?? this.expDate,
      moneyType: moneyType ?? this.moneyType,
    );
  }
}

Logs, stack traces

Unsupported operation: Loaded ObjectBox core dynamic library has unsupported version 0.13.0, expected ^0.14.0
loadObjectBoxLib
package:objectbox/…/bindings/bindings.dart:75
C
package:objectbox/…/bindings/bindings.dart:84
package:objectbox/src/native/bindings/bindings.dart        C
package:objectbox/…/bindings/bindings.dart:1
new Model
package:objectbox/…/native/model.dart:19
new Store
package:objectbox/…/native/store.dart:105
new TestEnv
test\test_env.dart:13
main.<fn>

Additional context

This is a package that manages the card database

greenrobot-team commented 2 years ago

I'm creating a unit test for a method that returns a Stream<List> and the test fails in all the ways I tried.

Loaded ObjectBox core dynamic library has unsupported version 0.13.0, expected ^0.14.0

You may have to update the ObjectBox library on your development machine. See the last step at https://github.com/objectbox/objectbox-dart/blob/main/objectbox/README.md#flutter about "In order to run Flutter unit tests locally on your machine".

greenrobot-team commented 2 years ago

Closing because this issue is missing details. Feel free to comment with additional details and we can re-open it.

agavrel commented 7 months ago

Got the same problem with version 2.3.0 and was able to have the error gone after downgrading to 2.2.0 (wasted 1 hour on this). Specifically the error was Loaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0

Was testing on a physical Android Device.

quebrandolink commented 7 months ago

Got the same problem with version 2.3.0 and was able to have the error gone after downgrading to 2.2.0 (wasted 1 hour on this). Specifically the error was Loaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0

Was testing on a physical Android Device.

mesmo problema para mim.

PKiman commented 7 months ago

Same problem on Android after upgrading to Objectbox 2.3.0. iOS is fine.

E/flutter ( 3783): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Loaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0
E/flutter ( 3783): #0      loadObjectBoxLib (package:objectbox/src/native/bindings/bindings.dart:110:5)
E/flutter ( 3783): #1      C (package:objectbox/src/native/bindings/bindings.dart:119:22)
E/flutter ( 3783): #2      C (package:objectbox/src/native/bindings/bindings.dart)
E/flutter ( 3783): #3      new Model (package:objectbox/src/native/model.dart:19:31)
E/flutter ( 3783): #4      new Store (package:objectbox/src/native/store.dart:192:21)
E/flutter ( 3783): <asynchronous suspension>
E/flutter ( 3783): 
quebrandolink commented 7 months ago

Tive o mesmo problema com a versão 2.3.0 e consegui eliminar o erro após fazer o downgrade para 2.2.0 (perdi 1 hora com isso). Especificamente, o erro foiLoaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0

Estava testando em um dispositivo Android físico.

Mesmo fazendo o downgrade da versão no pubspec ainda continuo recebendo o mesmo problema.

E/flutter (10233): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Loaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0 E/flutter (10233): #0 loadObjectBoxLib E/flutter (10233): #1 C E/flutter (10233): #2 C (package:objectbox/src/native/bindings/bindings.dart) E/flutter (10233): #3 new Model E/flutter (10233): #4 new Store E/flutter (10233): #5 openStore E/flutter (10233): #6 Objectbox.create E/flutter (10233): E/flutter (10233): #7 main E/flutter (10233): E/flutter (10233):

PKiman commented 7 months ago

Downgrade to 2.2.0 works but remove the caret syntax ^2.2.0

dependencies:
  flutter:
    sdk: flutter

  # Do not use caret syntax: objectbox: ^2.2.0 
  objectbox: 2.2.0 
  objectbox_sync_flutter_libs: 2.2.0
  objectbox_generator: 2.2.0 
quebrandolink commented 7 months ago

físico

Downgrade to 2.2.0 works but remove the caret syntax ^2.2.0

dependencies:
  flutter:
    sdk: flutter

  # Do not use caret syntax: objectbox: ^2.2.0 
  objectbox: 2.2.0 
  objectbox_sync_flutter_libs: 2.2.0
  objectbox_generator: 2.2.0 

Funcionou aqui, muito obrigado. Já estava ficando desesperado.

fisromildojr commented 7 months ago

Mesmo problema após atualizar para 2.3.0, problema resolvido após downgrade para 2.2.0.

pablopantaleon commented 7 months ago

same problem here — I've downgraded to 2.2.1

greenrobot-team commented 7 months ago

The Unsupported operation: Loaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0 error was fixed with 2.3.1 (which allows the new library version). See #563.

Thanks for reporting!

youngyouth22 commented 4 months ago

Downgrade to 2.2.0 works but remove the caret syntax ^2.2.0

dependencies:
  flutter:
    sdk: flutter

  # Do not use caret syntax: objectbox: ^2.2.0 
  objectbox: 2.2.0 
  objectbox_sync_flutter_libs: 2.2.0
  objectbox_generator: 2.2.0 

Thank 🙏🙏🙏