objectbox / objectbox-dart

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

run time error - Could not find io.objectbox:objectbox-android-objectbrowser:<3.5.1> #508

Closed DktPhl2019 closed 1 year ago

DktPhl2019 commented 1 year ago

I open emulator, run the app, and the error occurs. The error occurs each time I run the app. My Goal: I want to see Android App data saved using ObjectBox Admin on Windows.

The error message:

===========================================================================
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find io.objectbox:objectbox-android-objectbrowser:<3.5.1>.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/io/objectbox/objectbox-android-objectbrowser/<3.5.1>/objectbox-android-objectbrowser-<3.5.1>.pom
       - https://repo.maven.apache.org/maven2/io/objectbox/objectbox-android-objectbrowser/<3.5.1>/objectbox-android-objectbrowser-<3.5.1>.pom
       - https://storage.googleapis.com/download.flutter.io/io/objectbox/objectbox-android-objectbrowser/<3.5.1>/objectbox-android-objectbrowser-<3.5.1>.pom
     Required by:
         project :app

* 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 8s
Exception: Gradle task assembleDebug failed with exit code 1
================================================================================

Setup:

app/build.gradle:

android {
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.flutter_objectbox_example"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

configurations {
    debugImplementation {
        exclude group: 'io.objectbox', module: 'objectbox-android'
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    debugImplementation("io.objectbox:objectbox-android-objectbrowser:<3.5.1>")
}

Note: The app ran fine before adding:

configurations {
    debugImplementation {
        exclude group: 'io.objectbox', module: 'objectbox-android'
    }
}

dependencies {
    debugImplementation("io.objectbox:objectbox-android-objectbrowser:<3.5.1>")
}

objectbox.dart file:

class ObjectBox {

  late final Store store;
  late final Admin _admin;
  late final Box<Task> taskBox;
  ObjectBox._create(this.store) {
    if (Admin.isAvailable()) {
      _admin = Admin(store);}
    taskBox = Box<Task>(store);}

  static Future<ObjectBox> create() async {
    final documentsDirectory = await getApplicationDocumentsDirectory();
    final databaseDirectory = p.join(documentsDirectory.path, "obx-demo-relations");
    final store = await openStore(directory: databaseDirectory);
    return ObjectBox._create(store);}

  Stream<List<Task>> getTasks() {
    final qBuilderTasks = taskBox.query().order(Task_.dateCreated, flags: Order.descending);
    return qBuilderTasks
        .watch(triggerImmediately: true)
        .map((query) => query.find());}

  void saveTask(Task? task, String text) {
    if (text.isEmpty) { return; }
    if (task == null) {task = Task(text);} else {task.text = text; }
    taskBox.put(task);
    debugPrint('Saved ${task.text}');}
  void removeTask(int taskId) {taskBox.remove(taskId);}}

pubspec.yaml:

name: flutter_objectbox_example
description: Task-list example app using ObjectBox Flutter database with relations.
publish_to: 'none'
version: 1.0.0+1

environment:
  sdk: ">=2.14.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  objectbox: ^1.7.2
  objectbox_flutter_libs: any
  intl: any
  path_provider: ^2.0.10 # 2.0.11+ requires Flutter 2.8.0
  path: ^1.8.0
  objectbox_sync_flutter_libs: any

dev_dependencies:
  flutter_lints: ^2.0.1
  build_runner: ^2.0.0
  objectbox_generator: any

flutter:
  uses-material-design: true
greenrobot-team commented 1 year ago

@DktPhl2019 Replace debugImplementation("io.objectbox:objectbox-android-objectbrowser:<3.5.1>") with debugImplementation("io.objectbox:objectbox-android-objectbrowser:3.5.1"). Note the removal of the diamonds (<>).

I have updated https://docs.objectbox.io/data-browser#setup to make this more clear.

LouBerry commented 1 year ago

objectbox: ^1.7.2 objectbox_flutter_libs: any

For some reason I have to Setup like this.

dependencies {
     implementation "io.objectbox:objectbox-android:3.5.1"
     debugImplementation("io.objectbox:objectbox-android-objectbrowser:3.5.1")
}

But the docs are not mentioning this additional line.

github-actions[bot] commented 1 year ago

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.