mogol / flutter_realm

Realm via Platform Channels
https://pub.dev/packages/flutter_realm
MIT License
115 stars 18 forks source link

Class not found while querying database #13

Closed vavadiyahiren closed 4 years ago

vavadiyahiren commented 4 years ago

I have use the example module which is working like a charm.

I have copied the same module to one of my other app to test the realm and the pubspec.yaml also looking exactly same but as soon as i move to fetchwidget it give me following error like model class and database is not available.

W/System.err( 4031): java.lang.IllegalArgumentException: Class does not exist in the Realm and cannot be queried: Product W/System.err( 4031): at io.realm.DynamicRealm.where(DynamicRealm.java:178) W/System.err( 4031): at com.it_nomads.flutter_realm.FlutterRealm.onMethodCall(FlutterRealm.java:97) W/System.err( 4031): at com.it_nomads.flutter_realm.FlutterRealmPlugin.onMethodCall(FlutterRealmPlugin.java:73) W/System.err( 4031): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231) W/System.err( 4031): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93) W/System.err( 4031): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642) W/System.err( 4031): at android.os.MessageQueue.nativePollOnce(Native Method) W/System.err( 4031): at android.os.MessageQueue.next(MessageQueue.java:336) W/System.err( 4031): at android.os.Looper.loop(Looper.java:174) W/System.err( 4031): at android.app.ActivityThread.main(ActivityThread.java:7682) W/System.err( 4031): at java.lang.reflect.Method.invoke(Native Method) W/System.err( 4031): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516) W/System.err( 4031): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) E/flutter ( 4031): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Class does not exist in the Realm and cannot be queried: Product, Class does not exist in the Realm and cannot be queried: Product, [Ljava.lang.StackTraceElement;@186d198) E/flutter ( 4031): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7) E/flutter ( 4031): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33) E/flutter ( 4031): <asynchronous suspension> E/flutter ( 4031): #2 MethodChannelTransport.invokeMethod (package:flutter_realm/src/method_channel_transport.dart:18:16) E/flutter ( 4031): #3 Realm._invokeMethod (package:flutter_realm/src/realm.dart:81:16) E/flutter ( 4031): #4 Realm.allObjects (package:flutter_realm/src/realm.dart:86:7) E/flutter ( 4031): #5 _FetchWidgetState._fetchAll (package:flutterwhatsapp/fetch_widget.dart:67:41) E/flutter ( 4031): #6 _FetchWidgetState.initState (package:flutterwhatsapp/fetch_widget.dart:22:5) E/flutter ( 4031): #7 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58) E/flutter ( 4031): #8 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5) E/flutter ( 4031): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14) E/flutter ( 4031): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12) E/flutter ( 4031): #11 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16) E/flutter ( 4031): #12 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 4031): #13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2432:33) E/flutter ( 4031): #14 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:773:20) E/flutter ( 4031): #15 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5) E/flutter ( 4031): #16 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15) E/flutter ( 4031): #17 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9) E/flutter ( 4031): #18 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5) E/flutter ( 4031): #19 _rootRun (dart:async/zone.dart:1126:13) E/flutter ( 4031): #20 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter ( 4031): #21 _CustomZone.runGuarded (dart:async/zone.dart:925:7) E/flutter ( 4031): #22 _invoke (dart:ui/hooks.dart:259:10) E/flutter ( 4031): #23 _drawFrame (dart:ui/hooks.dart:217:3) E/flutter ( 4031): I/Surface ( 4031): opservice is null false

Any clue where i am making mistake to register table schema or model class ?

mogol commented 4 years ago

It seems that Realm wasn't correctly setup for that module. Check gradle configs

vavadiyahiren commented 4 years ago

@mogol I haven't updated the schema tables for android and ios. I did it and worked now so hence closing this issue.