Skip to content

Invalid argument(s): Unknown entity type PlayerEntity #315

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
QiXi opened this issue Sep 23, 2021 · 1 comment
Closed

Invalid argument(s): Unknown entity type PlayerEntity #315

QiXi opened this issue Sep 23, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@QiXi
Copy link

QiXi commented Sep 23, 2021

First time trying to use objectbox on examples of documentation

Unhandled exception: Invalid argument(s): Unknown entity type PlayerEntity

Dart CLI apps

  • ObjectBox version: ^1.2.0
  • Dart SDK: 2.14.2 (stable) on "linux_x64"
  • Null-safety enabled: yes
  • Reproducibility: always
  • OS: Ubuntu

Steps to reproduce

  1. Add ObjectBox to your project
  2. Define Entity Classes
@Entity()
class PlayerEntity {
  int id = 0;
  String? text;
  @Property(type: PropertyType.date)
  DateTime date;
  PlayerEntity({this.text, DateTime? date}) : date = date ?? DateTime.now();
}
  1. Generate ObjectBox code
  2. Run
void main() async {
  final store = openStore();
  final box = store.box<PlayerEntity>();
  final note = PlayerEntity(text: 'Hello'); 
  final id = box.put(note);        
  1. See error

Unhandled exception:
Invalid argument(s): Unknown entity type PlayerEntity
#0 Store._entityDef (package:objectbox/src/native/store.dart:261:7)
#1 Store.box (package:objectbox/src/native/store.dart:253:60)

@QiXi QiXi added the bug Something isn't working label Sep 23, 2021
@QiXi
Copy link
Author

QiXi commented Sep 23, 2021

This is a problem due to erroneous import
import '../lib/objectbox.g.dart';

Avoid relative imports for files in lib/.

@QiXi QiXi closed this as completed Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant