gpt4 book ai didi

android - 为什么 Carto Package Manager 在恢复后无法连接到它的数据库?

转载 作者:太空狗 更新时间:2023-10-29 14:39:38 26 4
gpt4 key购买 nike

我们正在使用 Carto Xamarin Mobile SDK 开发支持离线 map 的应用。它工作正常,直到用户在处理后不尝试恢复应用程序。 Activity 创建( Activity 使用 carto 包管理器)崩溃并出现异常:

Carto.PackageManager.CartoPackageManager.CartoPackageManager(string source, string dataFolder)<01980a2dae7148abb92e6b982667f448>:0
App.Droid.OfflineMaps.AndroidMapPackageManager.AndroidMapPackageManager()<76ae23b9271c407d865ebb6162639870>:0
App.Droid.Plugins.MapDownloader.Plugin.<>c.<Load>b__0_0()<76ae23b9271c407d865ebb6162639870>:0
MvvmCross.Platform.IoC.MvxSimpleIoCContainer.<>c__DisplayClass33_0<TInterface>.<RegisterSingleton>b__0()<4ddde23419c5494288c799fcdbb0f189>:0
MvvmCross.Platform.IoC.MvxSimpleIoCContainer.ConstructingSingletonResolver.Resolve()<4ddde23419c5494288c799fcdbb0f189>:0
MvvmCross.Platform.IoC.MvxSimpleIoCContainer.InternalTryResolve(Type type, MvxSimpleIoCContainer.IResolver resolver, ref object resolved
App.Core.ViewModels.Blocks.Maps.Offline.MapDownloaderOwnerViewModel.EnableMapDownloader(City city)<d6cca792b401420d922bc024

Here on line 105 you can see where exception is originally thrown.

在常规的进入页面中,它工作正常。PackageManager 请求通过以下方式在页面 ViewModel 的构造函数中发生:

 Mvx.Resolve<MapDownloadsManager>(); // It receivs as injection platform-dependent packageManager

看来问题出在数据库路径上。我们正在生成文件夹名称,然后按以下方式传递给 CartoPackageManager 构造函数:

 private static string CreateFolder(string folderPath)
{

var folder = GetDocumentDirectory(folderPath);

if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}

return folder;
}

private static string GetDocumentDirectory(string withFolder = null)
{
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

return withFolder == null ? documents : Path.Combine(documents, withFolder + "/");
}

您知道问题的根源在哪里吗?

P.S.: Carto SDK v 4.0.2, MvvmCross 4.4.0,遗憾的是现在无法更新到更新版本。

经过一些研究,我发现任务队列已重置,现在假设该应用程序实际上在源代码中崩溃了:

 std::string taskDbFileName = "tasks_v1.sqlite";
try {
_taskQueue = std::make_shared<PersistentTaskQueue>(createLocalFilePath(taskDbFileName));
}
catch (const std::exception& ex) {
//This looks like: Error while constructing PackageManager: Package encryption keys do not match, trying to remove
Log::Errorf("PackageManager: Error while constructing PackageManager::PersistentTaskQueue: %s, trying to remove...", ex.what());
_taskQueue.reset();
utf8_filesystem::unlink(taskDbFileName.c_str());
try {
_taskQueue = std::make_shared<PersistentTaskQueue>(createLocalFilePath(taskDbFileName));
}
catch (const std::exception& ex) {
**throw FileException("Failed to create/open package manager task queue database", taskDbFileName); //App gets here.**
}
}

包管理器的初始化:

 public class AndroidMapPackageManager : PackageManagerListener, IPackageManger
{
private readonly CartoPackageManager _packageManager;

public AndroidMapPackageManager()
{
var folder = CreateFolder(OfflineMapStrings.MapsFolderName); // /data/user/0/com.app.cityguide/files/mapmap2/

_packageManager =
new CartoPackageManager(OfflineMapsStrings.PackageManagerSource, folder)
{
PackageManagerListener = this
};
}
}

我是在构造函数在其他类订阅监听器事件后才开始工作的。而且,坦率地说,我从不阻止它。我需要它吗?

使用 FIllRam 时,再生率为 100%。我使用了不允许背景的 Debug模式,现在我尝试了 Ram Filler,结果是一样的。

许可证问题:

05-25 12:41:41.091 26101 26101 E carto-mobile-sdk: CartoPackageManager: RegisterLicense not called, using random key for package encryption!
05-25 12:41:41.094 26101 26101 E carto-mobile-sdk: PackageManager: Error while constructing PackageManager: Package encryption keys do not match, trying to remove

最佳答案

问题是我在 SplashActivity 中注册了许可证 key 。但是,在恢复启动 Activity 后没有显示,显然,没有执行许可证 key 的注册。我已将它移至自定义应用程序类并且它有效:

public class CustomApplication : Application
{
public override void OnCreate()
{
base.OnCreate();
MapView.RegisterLicense(CartoApiKey, this);
}
}

关于android - 为什么 Carto Package Manager 在恢复后无法连接到它的数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50470039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com