Skip to content
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

RealmException: No such table exists. Error code: 3020. #1798

Open
Mageshcoder opened this issue Sep 30, 2024 · 1 comment
Open

RealmException: No such table exists. Error code: 3020. #1798

Mageshcoder opened this issue Sep 30, 2024 · 1 comment

Comments

@Mageshcoder
Copy link

What happened?

I cannot able to get the data from my mongodb with this implementations. The lack of instructions from Realm didn't helped me.
I need to get the data from my mongodb with the appid and apikey (which i already have)

Repro steps

Copy and paste the below code and call the class instance on with GetIt in Locator file while calling the main.dart's main method.

Run it on Android emulator.

Version

Flutter version: 3.22.3

What Atlas Services are you using?

Atlas Device Sync

What type of application is this?

Flutter Application

Client OS and version

realm version 3.4.1 and flutter 3.22.3

Code snippets

import 'package:flutter/material.dart';
import 'package:realm/realm.dart';
import 'package:team_appcommon/team_appcommon.dart';
import 'package:team_inventory/src/common/realm/realm_models/realm_models.dart';
import 'package:team_inventory/src/common/secure_storage/secure_storage_constants.dart';

/// Class to handle the Realm Configuration
class InventoryRealmConfiguration {
late App _app;
User? _user;

/// Constructor
InventoryRealmConfiguration();

Future config() async {
const appId = "inventory";
final secureStorageManager = SecureStorageManager();

await secureStorageManager.setString(
  key: SecureStorageConstants.realmKey,
  value: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
);

final apiKey = await secureStorageManager.getString(
    key: SecureStorageConstants.realmKey);
if (apiKey == null || apiKey.isEmpty) {
  throw Exception("API Key not found in secure storage.");
}

final appConfig = AppConfiguration(appId);
_app = App(appConfig);

try {
  _user = await _app.logIn(Credentials.apiKey(apiKey));
  final itemData = await getItemData();
  print('itemData --- $itemData');
  print("DATA END...");
} catch (e, s) {
  print("Failed to log in to Realm: $e $s");
  rethrow;
}

}

/// Open the realm db
Realm openRealm(Configuration config) {
debugPrint('Open Realm Called');
return Realm(config);
}

List getItemData() {
if (_user == null) throw Exception("User is not logged in");

try {
  final ItemConfig = Configuration.flexibleSync(_user!, [Item.schema]);
  final itemRealm = openRealm(ItemConfig);
  itemRealm.subscriptions.update((mutableSubscriptions) {
    mutableSubscriptions.add(itemRealm.query<Item>("TRUEPREDICATE"));
  });

  debugPrint(
      'itemRealm.config.path.toString() -- ${itemRealm.config.path.toString()}');
  final itemData = itemRealm.all<Item>();
  return itemData.toList();
} catch (e, s) {
  debugPrint(e.toString());
  debugPrint('Error while fetching Item');
  debugPrint(s.toString());
  return [];
}

}
}

Stacktrace of the exception/crash you're getting

IOS LOG
----------
 
 
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...

Running Xcode build...

Xcode build done.                                           29.0s

no valid “aps-environment” entitlement string found for application

Debug service listening on ws://127.0.0.1:61342/VqHza5F5jbU=/ws

Syncing files to device iPhone 11 Pro Max...

flutter: log list indexes: []

flutter: Successfully logged in to Realm

flutter: DATA FETCHING STARTED...

flutter: Open Realm Called

flutter: itemRealm.config.path.toString() -- /Users/thiran-macstudio/Library/Developer/CoreSimulator/Devices/6918B9A4-CA08-477A-9809-DF114E1E75A6/data/Containers/Data/Application/95B22736-D29C-46A7-AE77-5131F14FD176/Documents/mongodb-realm/teaminventory-ehyjgvp/66e27ab0e0305e4770373d5f/default.realm

flutter: itemData --- []

flutter: Open Realm Called

flutter: RealmException: No such table exists. Error code: 3020.

flutter: Error while fetching invBalanceData

flutter: #0      _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:59:9)

flutter: #1      using (package:ffi/src/arena.dart:124:31)

flutter: #2      _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3)

flutter: #3      BoolEx.raiseLastErrorIfFalse (package:realm_dart/src/handles/native/error_handling.dart:25:7)

flutter: #4      RealmHandle._getPropertiesMetadata (package:realm_dart/src/handles/native/realm_handle.dart:460:87)

flutter: #5      RealmHandle.getObjectMetadata.<anonymous closure> (package:realm_dart/src/handles/native/realm_handle.dart:454:61)

flutter: #6      using (package:ffi/src/arena.dart:124:31)

flutter: #7      RealmHandle.getObjectMetadata (package:realm_dart/src/handles/native/realm_handle.dart:449:12)

flutter: #8      Realm._populateMetadata.<anonymous closure> (package:realm_dart/src/realm_class.dart:211:58)

flutter: #9      MappedIterator.moveNext (dart:_internal/iterable.dart:403:20)

flutter: #10     new RealmMetadata._ (package:realm_dart/src/realm_class.dart:873:28)

flutter: #11     Realm._populateMetadata (package:realm_dart/src/realm_class.dart:211:31)

flutter: #12     new Realm._ (package:realm_dart/src/realm_class.dart:144:5)

flutter: #13     new Realm (package:realm_dart/src/realm_class.dart:141:38)

flutter: #14     InventoryRealmConfiguration.openRealm (package:team_inventory/src/common/realm/realm_configuration.dart:65:12)

flutter: #15     InventoryRealmConfiguration.getInvBalanceData (package:team_inventory/src/common/realm/realm_configuration.dart:103:32)

flutter: #16     InventoryRealmConfiguration.config (package:team_inventory/src/common/realm/realm_configuration.dart:43:36)

flutter: <asynchronous suspension>

flutter: #17     setupDependencies.<anonymous closure> (package:team_inventory/locator.dart:153:9)

flutter: <asynchronous suspension>

flutter: #18     _GetItImplementation._register.<anonymous closure>.<anonymous closure> (package:get_it/get_it_impl.dart:1258:44)

flutter: <asynchronous suspension>

flutter: #19     FutureGroup.add.<anonymous closure> (package:async/src/future_group.dart:79:15)

flutter: <asynchronous suspension>

flutter:

flutter: invBalanceData --- []

flutter: Open Realm Called

flutter: FormatException: Invalid UTF-8 byte (at offset 21)

flutter: Error while fetching invCostData

flutter: #0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1760:7)

flutter: #1      Utf8Decoder.convert (dart:convert/utf.dart:349:37)

flutter: #2      Utf8Codec.decode (dart:convert/utf.dart:63:20)

flutter: #3      Utf8Pointer.toDartString (package:ffi/src/utf8.dart:49:17)

flutter: #4      PointerUtf8Ex.toRealmDartString (package:realm_dart/src/handles/native/from_native.dart:131:22)

flutter: #5      RealmErrorEx.toDart (package:realm_dart/src/handles/native/error_handling.dart:66:47)

flutter: #6      _getLastError (package:realm_dart/src/handles/native/error_handling.dart:44:30)

flutter: #7      _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:49:23)

flutter: #8      using (package:ffi/src/arena.dart:124:31)

flutter: #9      _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3)

flutter: #10     PointerEx.raiseLastErrorIfNull (package:realm_dart/src/handles/native/error_handling.dart:16:7)

flutter: #11     new RealmHandle.open (package:realm_dart/src/handles/native/realm_handle.dart:50:10)

flutter: #12     Realm._openRealm (package:realm_dart/src/realm_class.dart:206:24)

flutter: #13     new Realm._ (package:realm_dart/src/realm_class.dart:143:98)

flutter: #14     new Realm (package:realm_dart/src/realm_class.dart:141:38)

flutter: #15     InventoryRealmConfiguration.openRealm (package:team_inventory/src/common/realm/realm_configuration.dart:65:12)

flutter: #16     InventoryRealmConfiguration.getInvCostData (package:team_inventory/src/common/realm/realm_configuration.dart:129:28)

flutter: #17     InventoryRealmConfiguration.config (package:team_inventory/src/common/realm/realm_configuration.dart:46:33)

flutter: <asynchronous suspension>

flutter: #18     setupDependencies.<anonymous closure> (package:team_inventory/locator.dart:153:9)

flutter: <asynchronous suspension>

flutter: #19     _GetItImplementation._register.<anonymous closure>.<anonymous closure> (package:get_it/get_it_impl.dart:1258:44)

flutter: <asynchronous suspension>

flutter: #20     FutureGroup.add.<anonymous closure> (package:async/src/future_group.dart:79:15)

flutter: <asynchronous suspension>

flutter:

flutter: invCostData --- []

flutter: Open Realm Called

flutter: FormatException: Unexpected extension byte (at offset 24)

flutter: #0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1760:7)

flutter: #1      Utf8Decoder.convert (dart:convert/utf.dart:349:37)

flutter: #2      Utf8Codec.decode (dart:convert/utf.dart:63:20)

flutter: #3      Utf8Pointer.toDartString (package:ffi/src/utf8.dart:49:17)

flutter: #4      PointerUtf8Ex.toRealmDartString (package:realm_dart/src/handles/native/from_native.dart:131:22)

flutter: #5      RealmErrorEx.toDart (package:realm_dart/src/handles/native/error_handling.dart:66:47)

flutter: #6      _getLastError (package:realm_dart/src/handles/native/error_handling.dart:44:30)

flutter: #7      _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:49:23)

flutter: #8      using (package:ffi/src/arena.dart:124:31)

flutter: #9      _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3)

flutter: #10     PointerEx.raiseLastErrorIfNull (package:realm_dart/src/handles/native/error_handling.dart:16:7)

flutter: #11     new RealmHandle.open (package:realm_dart/src/handles/native/realm_handle.dart:50:10)

flutter: #12     Realm._openRealm (package:realm_dart/src/realm_class.dart:206:24)

flutter: #13     new Realm._ (package:realm_dart/src/realm_class.dart:143:98)

flutter: #14     new Realm (package:realm_dart/src/realm_class.dart:141:38)

flutter: #15     InventoryRealmConfiguration.openRealm (package:team_inventory/src/common/realm/realm_configuration.dart:65:12)

flutter: #16     InventoryRealmConfiguration.getInventoryData (package:team_inventory/src/common/realm/realm_configuration.dart:75:30)

flutter: #17     InventoryRealmConfiguration.config (package:team_inventory/src/common/realm/realm_configuration.dart:49:35)

flutter: <asynchronous suspension>

flutter: #18     setupDependencies.<anonymous closure> (package:team_inventory/locator.dart:153:9)

flutter: <asynchronous suspension>

flutter: #19     _GetItImplementation._register.<anonymous closure>.<anonymous closure> (package:get_it/get_it_impl.dart:1258:44)

flutter: <asynchronous suspension>

flutter: #20     FutureGroup.add.<anonymous closure> (package:async/src/future_group.dart:79:15)

flutter: <asynchronous suspension>

flutter:

flutter: inventoryData --- []

flutter: DATA END...
=========================================================================================================================================
 
Android LOG
-----------
 
Downloading android-arm-profile/darwin-x64 tools...

Downloading android-arm-release/darwin-x64 tools...

Downloading android-arm64-profile/darwin-x64 tools...

Downloading android-arm64-release/darwin-x64 tools...

Downloading android-x64-profile/darwin-x64 tools...

Downloading android-x64-release/darwin-x64 tools...

Launching lib/main.dart on sdk gphone64 arm64 in debug mode...

Running Gradle task 'assembleDebug'...

Warning: This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.

HostedDependency: 0.17.0

HostedDependency: ^3.0.0

Directory: '/Users/thiran-macstudio/.pub-cache/hosted/pub.dev/realm-3.4.1/android/src/main/cpp/lib'

Downloading Realm binaries for 3.4.1 to /var/folders/fb/d5djhl196dd1vgk6tn93lr0h0000gn/T/realm-binary-R6Fpkr/android.tar.gz

Extracting Realm binaries to /Users/thiran-macstudio/.pub-cache/hosted/pub.dev/realm-3.4.1/android/src/main/cpp/lib

extracting x86_64/librealm_dart.so

extracting arm64-v8a/librealm_dart.so

extracting armeabi-v7a/librealm_dart.so
 
Archive /var/folders/fb/d5djhl196dd1vgk6tn93lr0h0000gn/T/realm-binary-R6Fpkr/android.tar.gz extracted to /Users/thiran-macstudio/.pub-cache/hosted/pub.dev/realm-3.4.1/android/src/main/cpp/lib

Realm install command finished.

Note: /Users/thiran-macstudio/.pub-cache/hosted/pub.dev/google_mlkit_commons-0.7.1/android/src/main/java/com/google_mlkit_commons/InputImageConverter.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

✓ Built build/app/outputs/flutter-apk/app-debug.apk

Installing build/app/outputs/flutter-apk/app-debug.apk...

D/FlutterGeolocator( 8776): Attaching Geolocator to activity

D/FlutterGeolocator( 8776): Creating service.

D/FlutterGeolocator( 8776): Binding to location service.

D/FlutterGeolocator( 8776): Geolocator foreground service connected

D/FlutterGeolocator( 8776): Initializing Geolocator services

D/FlutterGeolocator( 8776): Flutter engine connected. Connected engine count 1

Debug service listening on ws://127.0.0.1:61281/TZCLLl9n9Kw=/ws

Syncing files to device sdk gphone64 arm64...

I/flutter ( 8776): log list indexes: []

I/flutter ( 8776): Successfully logged in to Realm

I/flutter ( 8776): DATA FETCHING STARTED...

I/flutter ( 8776): Open Realm Called

I/flutter ( 8776): itemRealm.config.path.toString() -- /data/data/com.thirantech.team_inventory/files/mongodb-realm/teaminventory-ehyjgvp/66e27ab0e0305e4770373d5f/default.realm

I/flutter ( 8776): itemData --- []

I/flutter ( 8776): Open Realm Called

I/flutter ( 8776): RealmException: Unsupported instruction. Error code: 1000.

I/flutter ( 8776): Error while fetching invBalanceData

I/flutter ( 8776): #0      _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:59:9)

I/flutter ( 8776): #1      using (package:ffi/src/arena.dart:124:31)

I/flutter ( 8776): #2      _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3)

I/flutter ( 8776): #3      PointerEx.raiseLastErrorIfNull (package:realm_dart/src/handles/native/error_handling.dart:16:7)

I/flutter ( 8776): #4      new RealmHandle.open (package:realm_dart/src/handles/native/realm_handle.dart:50:10)

I/flutter ( 8776): #5      Realm._openRealm (package:realm_dart/src/realm_class.dart:206:24)

I/flutter ( 8776): #6      new Realm._ (package:realm_dart/src/realm_class.dart:143:98)

I/flutter ( 8776): #7      new Realm (package:realm_dart/src/realm_class.dart:141:38)

I/flutter ( 8776): #8      InventoryRealmConfiguration.openRealm (package:team_inventory/src/common/realm/realm_configuration.dart:65:12)

I/flutter ( 8776): #9      InventoryRealmConfiguration.getInvBalanceData (package:team_inventory/src/common/realm/realm_configuration.dart:103:32)

I/flutter ( 8776): #10     InventoryRealmConfiguration.config (package:team_inventory/src/common/realm/realm_configuration.dart:43:36)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #11     setupDependencies.<anonymous closure> (package:team_inventory/locator.dart:153:9)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #12     _GetItImplementation._register.<anonymous closure>.<anonymous closure> (package:get_it/get_it_impl.dart:1258:44)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #13     FutureGroup.add.<anonymous closure> (package:async/src/future_group.dart:79:15)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): 

I/flutter ( 8776): invBalanceData --- []

I/flutter ( 8776): Open Realm Called

I/flutter ( 8776): RealmException: Name too long: �. Error code: 3010.

I/flutter ( 8776): Error while fetching invCostData

I/flutter ( 8776): #0      _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:59:9)

I/flutter ( 8776): #1      using (package:ffi/src/arena.dart:124:31)

I/flutter ( 8776): #2      _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3)

I/flutter ( 8776): #3      PointerEx.raiseLastErrorIfNull (package:realm_dart/src/handles/native/error_handling.dart:16:7)

I/flutter ( 8776): #4      new RealmHandle.open (package:realm_dart/src/handles/native/realm_handle.dart:50:10)

I/flutter ( 8776): #5      Realm._openRealm (package:realm_dart/src/realm_class.dart:206:24)

I/flutter ( 8776): #6      new Realm._ (package:realm_dart/src/realm_class.dart:143:98)

I/flutter ( 8776): #7      new Realm (package:realm_dart/src/realm_class.dart:141:38)

I/flutter ( 8776): #8      InventoryRealmConfiguration.openRealm (package:team_inventory/src/common/realm/realm_configuration.dart:65:12)

I/flutter ( 8776): #9      InventoryRealmConfiguration.getInvCostData (package:team_inventory/src/common/realm/realm_configuration.dart:129:28)

I/flutter ( 8776): #10     InventoryRealmConfiguration.config (package:team_inventory/src/common/realm/realm_configuration.dart:46:33)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #11     setupDependencies.<anonymous closure> (package:team_inventory/locator.dart:153:9)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #12     _GetItImplementation._register.<anonymous closure>.<anonymous closure> (package:get_it/get_it_impl.dart:1258:44)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #13     FutureGroup.add.<anonymous closure> (package:async/src/future_group.dart:79:15)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): 

I/flutter ( 8776): invCostData --- []

I/flutter ( 8776): Open Realm Called

I/flutter ( 8776): RealmException: Name too long: �. Error code: 3010.

I/flutter ( 8776): #0      _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:59:9)

I/flutter ( 8776): #1      using (package:ffi/src/arena.dart:124:31)

I/flutter ( 8776): #2      _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3)

I/flutter ( 8776): #3      PointerEx.raiseLastErrorIfNull (package:realm_dart/src/handles/native/error_handling.dart:16:7)

I/flutter ( 8776): #4      new RealmHandle.open (package:realm_dart/src/handles/native/realm_handle.dart:50:10)

I/flutter ( 8776): #5      Realm._openRealm (package:realm_dart/src/realm_class.dart:206:24)

I/flutter ( 8776): #6      new Realm._ (package:realm_dart/src/realm_class.dart:143:98)

I/flutter ( 8776): #7      new Realm (package:realm_dart/src/realm_class.dart:141:38)

I/flutter ( 8776): #8      InventoryRealmConfiguration.openRealm (package:team_inventory/src/common/realm/realm_configuration.dart:65:12)

I/flutter ( 8776): #9      InventoryRealmConfiguration.getInventoryData (package:team_inventory/src/common/realm/realm_configuration.dart:75:30)

I/flutter ( 8776): #10     InventoryRealmConfiguration.config (package:team_inventory/src/common/realm/realm_configuration.dart:49:35)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #11     setupDependencies.<anonymous closure> (package:team_inventory/locator.dart:153:9)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #12     _GetItImplementation._register.<anonymous closure>.<anonymous closure> (package:get_it/get_it_impl.dart:1258:44)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): #13     FutureGroup.add.<anonymous closure> (package:async/src/future_group.dart:79:15)

I/flutter ( 8776): <asynchronous suspension>

I/flutter ( 8776): 

I/flutter ( 8776): inventoryData --- []

I/flutter ( 8776): DATA END...

D/ProfileInstaller( 8776): Installing profile for com.thirantech.team_inventory

Relevant log output

No response

Copy link

sync-by-unito bot commented Sep 30, 2024

➤ PM Bot commented:

Jira ticket: RDART-1101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant