objectbox/objectbox-dart

Error after upgrading: Unsupported operation: ObjectBox platform-specific library not compatible

openl4m4 opened this issue · 8 comments

Hello everyone,

I just upgraded Flutter & ObjectBox from 2.3.1 to 2.5.1 today and now I'm having issues launching the project. Here is the error I'm facing when doing a Flutter run in vscode:

E/flutter ( 4121): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: ObjectBox platform-specific library not compatible: is 0.18.1 (3.7.0-2023-08-22 (http, admin)), expected 0.21.0 (3.8.0-2024-02-13) or newer. For Flutter, check if the ObjectBox Pod or objectbox-android-objectbrowser need to be updated. For Dart, re-run the install.sh script to download the latest version.
E/flutter ( 4121): #0      loadObjectBoxLib (package:objectbox/src/native/bindings/bindings.dart:133:5)
E/flutter ( 4121): #1      C (package:objectbox/src/native/bindings/bindings.dart:144:22)
E/flutter ( 4121): #2      C (package:objectbox/src/native/bindings/bindings.dart)
E/flutter ( 4121): #3      new Model (package:objectbox/src/native/model.dart:19:31)
E/flutter ( 4121): #4      new Store (package:objectbox/src/native/store.dart:225:21)
E/flutter ( 4121): #5      openStore (package:xxx/objectbox.g.dart:371:14)
E/flutter ( 4121): <asynchronous suspension>
E/flutter ( 4121): #6      ObjectBox.create (package:xxx/models/objectbox.dart:44:19)
E/flutter ( 4121): <asynchronous suspension>
E/flutter ( 4121): #7      main (package:xxx/main.dart:16:15)
E/flutter ( 4121): <asynchronous suspension>
E/flutter ( 4121): 
D/ProfileInstaller( 4121): Installing profile for com.example.xxx
Application finished.

Exited.

Here's my pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  objectbox: ^2.5.1
  objectbox_flutter_libs: ^2.5.1
  intl: ^0.19.0
  path_provider: ^2.1.2
  path: ^1.9.0
  image_picker: ^1.0.4
  popover: ^0.3.0
  collection: ^1.18.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^2.0.0
  objectbox_generator: ^2.5.1

The output of my Flutter doctor:

[✓] Flutter (Channel stable, 3.19.5, on Debian GNU/Linux 12 (bookworm) 6.7.9-amd64, locale en_US.UTF-8)
    • Flutter version 3.19.5 on channel stable at /home/kin/workspace/mobile-apps-env/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (5 days ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    • Android SDK at /home/kin/workspace/mobile-apps-env/Android/Sdk/
    • Platform android-34, build-tools 33.0.0-rc1
    • ANDROID_HOME = ~/workspace/mobile-apps-env/Android/Sdk
    • ANDROID_SDK_ROOT = ~/workspace/mobile-apps-env/Android/Sdk
    • Java binary at: /home/kin/workspace/mobile-apps-env/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
    • Debian clang version 14.0.6
    • cmake version 3.25.1
    • ninja version 1.11.1
    • pkg-config version 1.8.1

[✓] Android Studio (version 2022.3)
    • Android Studio at /home/kin/workspace/mobile-apps-env/android-studio
    • Flutter plugin version 76.1.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /home/kin/workspace/mobile-apps-env/android-studio
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

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

[✓] Connected device (3 available)
    • SM N981B (mobile) • RFCNA0K7Q1N • android-arm64  • Android 13 (API 33)
    • Linux (desktop)   • linux       • linux-x64      • Debian GNU/Linux 12 (bookworm) 6.7.9-amd64
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 123.0.6312.86

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

I've checked the doc, many issues and other resources and added the dependencies & configuration part in my build.gradle:

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

#--- added this after the upgrade ---#
configurations {
    debugImplementation {
        exclude group: 'io.objectbox', module: 'objectbox-android'
    }
}

dependencies {
    // implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    // Add objectbox-android-objectbrowser only for debug builds.
    // Warning: when objectbox_flutter_libs updates check if version
    // needs update, e.g. check https://github.com/objectbox/objectbox-dart/releases.
    def objectboxVersion = "3.8.0"
    debugImplementation("io.objectbox:objectbox-android-objectbrowser:$objectboxVersion")
    // releaseImplementation("io.objectbox:objectbox-android:$objectboxVersion")
}
#-------------------------------------------------#

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

I also got the new libobjectbox.so from the following script, did a search on my system for the lib & put it inside my project:

wget https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh
cp /usr/lib/libobjectbox.so /home/kin/workspace/xxx/xxx/build/linux/x64/debug/_deps/objectbox-download-src/lib/
cp  /usr/lib/libobjectbox.so /home/kin/workspace/xxx/xxx/build/linux/x64/debug/bundle/lib/

Unfortunately, I still have the same issue. Do you spot any issues that I could fix in my conf or elsewhere?

Thanks a lot.

Kieran

I guess you are trying to run it on an Android device? The objectbox-android-objectbrowser version looks good. Maybe a caching issue? Did you try flutter clean and then running again?

Well, thanks for the confirmation.

I tried a flutter clean but it's the same problem at the end. A rollback to these packages values works well :

dependencies:
  flutter:
    sdk: flutter
  objectbox: ^2.3.1
  objectbox_flutter_libs: any
  intl: any
  path_provider: ^2.0.10
  path: ^1.8.3
  image_picker: ^1.0.4

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2  
  google_fonts: ^6.1.0
  collection: ^1.18.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^2.0.0
  objectbox_generator: any    

Tried to reproduce but not having any issues in VS Code and running on Android. Maybe manually delete the Flutter/Dart build folders?

In any case, you can try with one of the examples to check if it's an issue with your project. (Make sure to comment out the dependency_overrides in the pubspec though).

I have the same issue.

Changing dependencies at andoid\app\build.gradle solved my problem.

dependencies {
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.material:material:1.6.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "io.objectbox:objectbox-android:3.8.0"
    debugImplementation("io.objectbox:objectbox-android-objectbrowser:3.8.0")
}

@bahadirarslan Thanks, but the original poster already has the correct version of objectbox-android-objectbrowser added.

@bahadirarslan Thanks, but the original poster already has the correct version of objectbox-android-objectbrowser added.

You are right, sorry I didn't notice that.