Xamarin Android MvvmCross链接问题

时间:2018-05-23 19:38:23

标签: visual-studio xamarin.android mvvmcross

我正在使用MvvmCross构建我的第一个Xamarin Android发行版。就像大多数有类似问题的人一样,应用程序在调试模式下运行正常,但不能通过链接发布。我被困住了几天,但仍无法解决。请帮助。

我有最新的Visual Studio 2017 v15.7.2,.net 4.7.03056,Xamarin 4.10.0.48&已安装Android SDK 8.1。

要解决此问题,我开始以调试模式运行,并链接“仅限Sdk程序集”而不使用共享运行时。发生以下错误:

    05-24 02:21:52.490 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
    05-24 02:21:52.490 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.dll'.
    05-24 02:21:52.490 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.exe'.
    05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.exe'.
    05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
    05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/storage/emulated/0/Android/data/.../files/.__override__/System.Runtime.dll'.
    05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.dll'.
    05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.exe'.
    05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/storage/emulated/0/Android/data/xxx.Droid/files/.__override__/System.Runtime.exe'.
    05-24 02:21:52.493 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.exe'.
    05-24 02:21:52.493 W/Mono( 9114) : The following assembly referenced from /storage/emulated/0/Android/data/xxx.Droid/files/.__override__/MvvmCross.Platform.dll could not be loaded:
    05-24 02:21:52.493 W/Mono( 9114) :      Assembly:   System.Runtime(assemblyref_index=0)
    05-24 02:21:52.493 W/Mono( 9114) :      Version:    4.0.0.0
    05-24 02:21:52.493 W/Mono( 9114) :      Public Key: b03f5f7f11d50a3a
    05-24 02:21:52.493 W/Mono( 9114) : The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly(/storage/emulated/0/Android/data/xxx.Droid/files/.__override__/).
    05-24 02:21:52.493 D/Mono( 9114) : Failed to load assembly MvvmCross.Platform[0xe7ec5ea0].
    05-24 02:21:52.493 W/        ( 9114): Could not load signature of MvvmCross.Platform.Droid.Views.MvxEventSourceActivity:add_CreateWillBeCalled due to: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.assembly:System.Runtime, Version= 4.0.0.0, Culture= neutral, PublicKeyToken= b03f5f7f11d50a3a type:<unknown type> member:(null) signature:<none>
    Unhandled Exception:

    System.TypeLoadException: Could not resolve the signature of a virtual method

    05-24 02:24:36.309 D/Mono( 9114) : Assembly Ref addref xxx.Droid[0xe7ec5240] -> MvvmCross.Plugins.ResxLocalization[0xe7ec6260]: 2
    05-24 02:24:36.310 D/Mono    ( 9114): Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
    05-24 02:24:36.310 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.dll'.
    05-24 02:24:36.310 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.exe'.
    05-24 02:24:36.310 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.exe'.
    05-24 02:24:36.311 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
    05-24 02:24:36.311 D/Mono( 9114) : Assembly Loader probing location: '/storage/emulated/0/Android/data/xxx.Droid/files/.__override__/System.Runtime.dll'.

它似乎正在尝试找到旧版本的System.Runtime。我将bindingRedirect添加到了app.conig。没有运气:删除所有dependentAssembly也没有用。我的System.Runtime版本是4.3.0

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" />
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

当使用“仅限Sdk程序集”在发布模式下运行时,我在日志中收到以下消息(抱歉无法将其复制为文本但只能屏幕截图):

enter image description here

这看起来更像是与链接有关。我有标准的LinkerPleaseInclude所有属性和&amp;在我指定的xml中绑定的方法。但是,在到达我自己的代码之前,应用程序在启动屏幕上崩溃。这是我的启动画面的代码,只是样本中未触及的一个克隆。

namespace xxx.Droid
{
    [Activity(
        Label = "xxx.Droid"
        , MainLauncher = true
        , Icon = "@drawable/icon"
        , Theme = "@style/Theme.Splash"
        , NoHistory = true
        , ScreenOrientation = ScreenOrientation.Portrait)]

    public class SplashScreen : MvxSplashScreenActivity
    {
        public SplashScreen()
            : base(Resource.Layout.splash_screen)
        {
        }
    }
}

总之,

我现在有3个问题:

  1. 调试模式下的BindingRedirect不起作用。无法在调试模式下使用链接运行使问题解决更加困难

  2. 在发布模式下,启动画面崩溃。但是,我无法看到日志中缺少的内容

  3. 是否有任何来自日志的规则/提示,以找出链接器中应包含哪些内容?

  4. 非常感谢您的帮助

    尼克

0 个答案:

没有答案