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

Loaded ObjectBox core dynamic library has unsupported version 0.18.1, expected ^0.19.0 #563

Closed linememory closed 7 months ago

linememory commented 7 months ago

I always get the following error. I tried it with the objectbox examples like objectbox_demo_relations

E/flutter ( 5963): [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 ( 5963): #0      loadObjectBoxLib
bindings.dart:110
E/flutter ( 5963): #1      C
bindings.dart:119
E/flutter ( 5963): #2      C (package:objectbox/src/native/bindings/bindings.dart)
bindings.dart:1
E/flutter ( 5963): #3      new Model
model.dart:19
E/flutter ( 5963): #4      new Store
store.dart:192
E/flutter ( 5963): #5      openStore
objectbox.g.dart:93
E/flutter ( 5963): #6      ObjectBox.create
objectbox.dart:49
E/flutter ( 5963): <asynchronous suspension>
E/flutter ( 5963): #7      main
main.dart:19
E/flutter ( 5963): <asynchronous suspension>

This happens on Windows and on linux on a Lenovo Thinkpad yoga from 2017. I can not test it on an other machine atm. I used bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh) to install the shared library and also downloaded the 0.19.0 and put it in /usr/lib and on Windows 11 in System32. I installed flutter manually.

flutter doctor

[✓] Flutter (Channel stable, 3.13.5, on Pop!_OS 22.04 LTS 6.4.6-76060406-generic, locale en_US.UTF-8)
    • Flutter version 3.13.5 on channel stable at /home/lukas/Development/SDK/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12fccda598 (3 days ago), 2023-09-19 13:56:11 -0700
    • Engine revision bd986c5ed2
    • Dart version 3.1.2
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/lukas/Android/Sdk
    • Platform android-33, build-tools 34.0.0
    • Java binary at: /home/lukas/Apps/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2022.3)
    • Android Studio at /home/lukas/Apps/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 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.82.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.72.0

[✓] Connected device (3 available)
    • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Linux (desktop)            • linux         • linux-x64      • Pop!_OS 22.04 LTS 6.4.6-76060406-generic
    • Chrome (web)               • chrome        • web-javascript • Google Chrome 117.0.5938.88

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

• No issues found!
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 

https://github.com/objectbox/objectbox-dart/issues/309#issuecomment-1729572003

linememory commented 7 months ago

Same problem with 2.2.0

PKiman commented 7 months ago

Same problem with 2.2.0

And 2.1.0 too?

try to remove the caret syntax ^ from ^2.2.0. This worked for me.

linememory commented 7 months ago

Oh my bad. Now it works. Forgot to remove the caret.

ririlya94 commented 7 months ago

was wondering why need to downgrade? is 2.3.0 can't be use?

PKiman commented 7 months ago

Because Objectbox 2.3.0 does not work on Android. See error in original post.

techouse commented 7 months ago

Confirmed, v2.2.1 works, v2.3.0 throws this error on Android.

greenrobot commented 7 months ago

Please check 2.3.1-dev.0 if it works for you... Sorry, discovered some bug, dev.1 coming soon...

greenrobot commented 7 months ago

2.3.1-dev.1 seems good, as soon as we have some external confirmation, this will become 2.3.1. So let us know...

Gobbo89 commented 7 months ago

2.3.1-dev.1 seems good, as soon as we have some external confirmation, this will become 2.3.1. So let us know...

2.3.1-dev.1 works on Android, the error we had with 2.3.0 is gone.

greenrobot commented 7 months ago

2.3.1 is published with a fix.

hongfeiyang commented 5 months ago

I am still getting this issue on Android with 2.3.1, even after i cleaned everything. Flutter 3.16.0

greenrobot-team commented 5 months ago

@hongfeiyang Can you please share how your project is set up and more details (e.g. feel free to open a new issue and refer to this one)? Otherwise we can't really find out why this still happens for you.

hongfeiyang commented 5 months ago

@hongfeiyang Can you please share how your project is set up and more details (e.g. feel free to open a new issue and refer to this one)? Otherwise we can't really find out why this still happens for you.

in pubspec: objectbox: ^2.3.1 objectbox_flutter_libs: any 'objectbox_generator: any'

pubspec.lock

  objectbox:
    dependency: "direct main"
    description:
      name: objectbox
      sha256: "4b645c71771b87188442143a50c55ab238a8e60fe367b6a0968c0842292ffb30"
      url: "https://pub.dev"
    source: hosted
    version: "2.3.1"
  objectbox_flutter_libs:
    dependency: "direct main"
    description:
      name: objectbox_flutter_libs
      sha256: e9a3d8e3ce0d47d6fc942921ef0444a238cd4258e8fcefe13b994cf984a8bf61
      url: "https://pub.dev"
    source: hosted
    version: "2.3.1"
  objectbox_generator:
    dependency: "direct dev"
    description:
      name: objectbox_generator
      sha256: aaffef7eb51b4d911bb00a7c52b19b55fe3e5a69de8ec56552cf35550a1e9beb
      url: "https://pub.dev"
    source: hosted
    version: "2.3.1"

build.gradle

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    // Add objectbox-android-objectbrowser only for debug builds.
    // Replace <version> with the included objectbox-android version,
    // e.g. check https://github.com/objectbox/objectbox-dart/releases
    // Warning: when ObjectBox for Dart updates check if <version>
    // needs to be updated.
    debugImplementation("io.objectbox:objectbox-android-objectbrowser:3.5.1")
}
...
    configurations {
        all {
            exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
        }
        // Tell Gradle to exclude the objectbox-android dependency
        // that is added by objectbox_flutter_libs for debug builds.
        debugImplementation {
            exclude group: 'io.objectbox', module: 'objectbox-android'
        }
    }

def compileSDKVersion = 33
if ((flutter.compileSdkVersion as int) > 33) {
    compileSDKVersion = flutter.compileSdkVersion as int
}

def minSDKVersion = flutter.minSdkVersion as int
if (minSDKVersion < 24) {
    minSDKVersion = 24
}

those are the important settings. Project was working fine before on 2.2.0 until I pub upgrade auto updates it to 2.3.1 clean project and rebuild does not work pub cache repair does not work either Windows, Flutter 3.16.0, Android SDK API 34

It is too hard to describe the entire setup, let me know what do you need to look into this issue

Also for iOS I know that pod updates it to 0.19.0 in podfile.lock, but for android I dont even know if there exist a thing like that to check the installed version

greenrobot-team commented 5 months ago

@hongfeiyang Try to update the objectbox-android-objectbrowser dependency to the one listed in the release notes, e.g. for 2.3.1 it should be at least 3.7.0.

hongfeiyang commented 5 months ago

Thanks! will give it a go

Sent from Gmail Mobile

On Mon, 20 Nov 2023 at 7:25 pm, Uwe - ObjectBox @.***> wrote:

@hongfeiyang https://github.com/hongfeiyang Try to update the objectbox-android-objectbrowser dependency to the one listed in the release notes, e.g. for 2.3.1 https://github.com/objectbox/objectbox-dart/releases/tag/v2.3.1 it should be at least 3.7.0.

— Reply to this email directly, view it on GitHub https://github.com/objectbox/objectbox-dart/issues/563#issuecomment-1818442039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETIN4FZWTVSQEIZX4XDFTTYFMHYBAVCNFSM6AAAAAA5DEGIZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJYGQ2DEMBTHE . You are receiving this because you were mentioned.Message ID: @.***>

hongfeiyang commented 5 months ago

@hongfeiyang Try to update the objectbox-android-objectbrowser dependency to the one listed in the release notes, e.g. for 2.3.1 it should be at least 3.7.0.

Thanks this solves the problem :)