Skip to content

After Android saves the data, an error is reported when running again, and there will be a flash back when I debug the breakpoint #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Aaron009 opened this issue Aug 23, 2022 · 6 comments
Labels
more info required Needs more info to become actionable. Auto-closed if no response. question How to do something/general question

Comments

@Aaron009
Copy link

The error screenshot is as follows:
image

image

@Aaron009 Aaron009 added the bug Something isn't working label Aug 23, 2022
@greenrobot-team
Copy link
Member

Thanks! Can you please share additional details (code snippets, what versions you are using, instructions) that allow us to reproduce this problem?

@greenrobot-team greenrobot-team added more info required Needs more info to become actionable. Auto-closed if no response. and removed bug Something isn't working labels Aug 23, 2022
@Aaron009
Copy link
Author

Aaron009 commented Aug 23, 2022

bug example:
https://github.com/Aaron009/bug_objectbox

iOS works fine,

When Android is opened for the second time, an error will be reported.

@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Aug 24, 2022
@Aaron009 Aaron009 changed the title In the device android emulator, after I save the data, re-run will run with an error. After Android saves the data, an error is reported when running again, and there will be a flash back when I debug the breakpoint Aug 24, 2022
@greenrobot-team
Copy link
Member

If I read the code correctly, it may call openStore() multiple times. Try to call initDataBase() from the main method of your app instead. Like in our examples:

Future<void> main() async {
// This is required so ObjectBox can get the application directory
// to store the database in.
WidgetsFlutterBinding.ensureInitialized();
objectbox = await ObjectBox.create();
runApp(const MyApp());
}

@greenrobot-team greenrobot-team added more info required Needs more info to become actionable. Auto-closed if no response. question How to do something/general question labels Aug 24, 2022
@Aaron009
Copy link
Author

If I read the code correctly, it may call openStore() multiple times. Try to call initDataBase() from the main method of your app instead. Like in our examples:

Future<void> main() async {
// This is required so ObjectBox can get the application directory
// to store the database in.
WidgetsFlutterBinding.ensureInitialized();
objectbox = await ObjectBox.create();
runApp(const MyApp());
}

I'm pretty sure it's only called once.
I've hit print log and also found that it's only called once.

I/flutter (18852): initDataBase initDataBase!
I/flutter (18852): getBox getBox!
E/flutter (18852): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: RangeError (byteOffset): Invalid value: Valid value range is empty: 0
E/flutter (18852): #0      ObjectCollectorError.throwIfError (package:objectbox/src/native/bindings/data_visitor.dart:58:24)
E/flutter (18852): #1      Query.find (package:objectbox/src/native/query/query.dart:827:18)
E/flutter (18852): #2      DataBase.getLanguageData (package:bug/main.dart:196:25)
E/flutter (18852): #3      _MyHomePageState.initDataBase (package:bug/main.dart:79:35)
E/flutter (18852): <asynchronous suspension>

@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Aug 25, 2022
@greenrobot-team
Copy link
Member

E/flutter (18852): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: RangeError (byteOffset): Invalid value: Valid value range is empty: 0

This is #460, a fix is available with the latest release: https://github.com/objectbox/objectbox-dart/releases/tag/v1.6.2

@greenrobot-team greenrobot-team added the more info required Needs more info to become actionable. Auto-closed if no response. label Aug 29, 2022
@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info required Needs more info to become actionable. Auto-closed if no response. question How to do something/general question
Projects
None yet
Development

No branches or pull requests

2 participants