0

I'm trying to create a new instance of SDKNativeEngine in this way

SDKOptions sdkOptions =
          SDKOptions.withAccessKeySecretAndCachePathCacheSizeAndPersistentMapPath(
              accessKeyId, accessKeySecret, externalPath, cacheSizeBytes, externalPath);

     
// Trying to use external map folder
await SDKNativeEngine.sharedInstance.internaldispose(() async {
          SDKNativeEngine sdkNativeEngine;
          try {
            sdkNativeEngine = SDKNativeEngine(sdkOptions);
          } on InstantiationException {
            // Handle exception.
            print('$InstantiationException');
          }
          SDKNativeEngine.sharedInstance = sdkNativeEngine;
          isLoaded = true;

          MapDownloadService mapDownloadService = ServiceProvider.of<MapDownloadService>();
          await mapDownloadService?.fetchListRegions(forceRefresh: true);
        });

Where the important thing for me is to set a custom path to save the map (externalPath variable), the value is /storage/<FB39-1114(SdCard)>/Android/data//files/MyMaps, but I'm getting this error

[ERROR] SDKNativeEngine - Failed to lock cache directory. Check the log above for more details. This usually happens when the second instance of SDKNativeEngine is created with the same access key id as the existing one (for example, shared instance). The issue might be fixed if SDKNativeEngine.dispose() method is called on existing instance before the creation of the new one. Keep in mind that the instance of SDKNativeEngine might exist in a separate process.

Also the map data is not saved in the custom path, it's always saved in the internal private storage

1 Answers1

0

SDK created global singleton of SDKNativeEngine which you have to dispose before creation of the new one.

The easiest way is to do something like - await SDKNativeEngine.sharedInstance?.dispose(); before you create SDKNativeEngine. But perhaps you don’t even need the new instance, just put your app code to info.plist and to Android’s Manifest and then only set app secret on shared instance? Like - SDKNativeEngine.sharedInstance.setAccessKeySecret(accessKeySecret)

For storing map data in external storage - If you open documentation for SDKOptions you may see all the options which you need.

enter image description here

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33