【问题标题】:Is there an issue with the latest Kentico Delivery Client and Release build in AndroidAndroid 中最新的 Kentico Delivery Client 和 Release 版本是否存在问题
【发布时间】:2019-04-19 03:37:57
【问题描述】:

我在使用 Xamarin.Android 中的最新 DeliveryClient 时遇到问题。 以下代码 sn-p 在 Debug 构建中运行良好。

但是,通过取消选中 Android 项目属性中的两个打包属性项,使用共享运行时使用快速部署,我得到了运行时错误。当您归档要安装在设备上的 APK 时,您必须取消选中这些。 一旦我这样做了,我会得到下面的堆栈跟踪,这不是很有帮助,但似乎 http 请求只是在某个地方发生并且没有被执行。

这让我想知道是否有人在 Android 发布版本中成功使用了这个最新版本的 DeliveryClient。这在 DeliveryClientBuilder 之前的早期版本中不会发生。

    DeliveryClient client = DeliveryClientBuilder
                    .WithOptions(builder => builder
                        .WithProjectId("myProjectId")
                        .UseProductionApi
                        .WithMaxRetryAttempts(5)
                    .Build())
                    .Build();

     Task<string> content = Task.Run(async () =>
                {
                    var res = client.GetItemAsync("hello").Result;
                    var helloFromKC = res.Item.GetString("message_from_kc");
                    return helloFromKC;
                });

04-18 18:24:16.408 I/mono-stdout(17908):出现一个或多个错误。 出现一个或多个错误。
在 System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] 在 /Users/builder/jenkins/workspace/xamarin-android-d15-8/xamarin-android/external/mono/mcs/class/referencesource /mscorlib/system/threading/Tasks/Task.cs:2164 04-18 18:24:16.578 I/mono-stdout(17908): 在 System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011]在 /Users/builder/jenkins/workspace/xamarin-android-d15-8/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2164 在 System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] 在 /Users/builder/jenkins/workspace/xamarin-android-d15-8/xamarin-android/external/mono/ mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:562 在 System.Threading.Tasks.Task1[TResult].get_Result () [0x00000] 在 /Users/builder/jenkins/workspace/xamarin-android-d15-8/xamarin-android/external/mono/mcs/class/referencesource/ mscorlib/system/threading/Tasks/Future.cs:532 在 App1.MainActivity+c__DisplayClass3_0+d.MoveNext () [0x00014] 在 C:\TestApps\AndroidKenticoTest\App1\App1\MainActivity.cs:68 04-18 18:24:16.579 I/mono-stdout(17908 ): 在 System.Threading.Tasks.Task1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] 在 /Users/builder/jenkins/workspace/xamarin-android-d15-8/xamarin-android/external/mono/ mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:562

【问题讨论】:

  • 您能否确定在此设置下运行流畅的 SDK 版本?
  • 它似乎是在版本 6 中引入的。版本 4 和 5 使用此设置。此外,版本 6 没有引入 DeliveryClientBuilder,因此这似乎不是问题。
  • 嗨,戴夫,仅供参考,我终于能够重现该问题并进一步调查。

标签: xamarin.android kentico-kontent


【解决方案1】:

我终于调试了这种行为的根源。在 Xamarin 中,一些反射方法是可移植类库 (PCL) 中的 not available(或至少不完全支持),GetExecutingAssembly() 是其中一种方法。

因此,Kentico Cloud Delivery 的 SDK 私有方法 GetSdkVersion()GetSdkPackageId() 使用此方法抛出异常。

作为一种快速解决方法,您可以直接将 SDK 引用为 project 并注释掉 GetSdkPackageId()GetSdkVersion() 方法的主体(只返回一些虚拟字符串。)我将创建一个问题并尝试在 SDK(以及 Nuget 包)中修复它。

更新 1:除了(不完全)Xamarin 中的 GetExecutingAssembly() 支持之外,it's not possible 似乎在使用非共享运行时(生产模式)时获取程序集的有效路径位置。

更新 2:在 GitHub 上创建 issue

更新 3:SDK 中的问题is fixed 和新修补的version 10.0.1 已发布。让我知道它是否适合你。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    • 2020-12-18
    • 2018-10-15
    • 2014-03-19
    相关资源
    最近更新 更多