【问题标题】:Linker and LayoutInflater.Inflate(int, Android.Views.ViewGroup)链接器和 LayoutInflater.Inflate(int, Android.Views.ViewGroup)
【发布时间】:2014-01-01 21:10:41
【问题描述】:

我在大多数视图中都成功使用了 Mvx.MvxFrameControl。其中一个视图使用从头开始构建的自定义控件。仅在发布模式下,当放大此视图时,应用会崩溃。

日志显示一个方法已经被优化掉并且丢失了。

at <unknown> <0xffffffff>
at (wrapper managed-to-native) object.wrapper_native_...
at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue[])
at Android.Views.LayoutInflater.Inflate(int, Android.Views.ViewGroup)
at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.CommonInflate(int,Android.View.ViewGroup, IMvxLayoutInfactorFactory)
....

所以我尝试将这些行添加到 MainApp 类的 MainApp 构造函数中。

public class MainApp : Application
{
    public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
    {
        //For linker only
        Android.Views.LayoutInflater inflater = null;
        if(inflater != null)
            inflater.Inflate(0, null);
    }

我希望链接器不会优化该方法。但没有运气。该方法仍然缺失。如何解决这个问题?

编辑:我在 Android 4.3 模拟器的发布模式下尝试了 Cheesebaron.Horizo​​ntalListView.Demo 项目,它也崩溃了。

编辑:似乎链接问题与派生自AdatperView&lt;T&gt;的所有类有关

编辑:更多堆栈跟踪

01-03 03:20:46.185 E/mono-rt ( 2106): Stacktrace:
01-03 03:20:46.185 E/mono-rt ( 2106): 
01-03 03:20:46.195 E/mono-rt ( 2106):   at <unknown> <0xffffffff>
01-03 03:20:46.195 E/mono-rt ( 2106):   at (wrapper managed-to-native)    object.wrapper_native_0xb6360af0 (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
01-03 03:20:46.195 E/mono-rt ( 2106):   at Android.Runtime.JNIEnv.CallObjectMethod     (intptr,intptr,Android.Runtime.JValue[]) <0x00068>
01-03 03:20:46.195 E/mono-rt ( 2106):   at Android.Views.LayoutInflater.Inflate (int,Android.Views.ViewGroup) <0x00147>

【问题讨论】:

    标签: linker xamarin.android


    【解决方案1】:

    这是a bug。解决方法是提供一个custom linker script,方法是向您的项目添加一个构建操作LinkDescription 的新文件和文件内容:

    <linker>
      <assembly fullname="Mono.Android">
        <type fullname="Android.Widget.AdapterView">
          <method name="GetGetAdapterHandler" />
          <method name="GetSetAdapter_Landroid_widget_Adapter_Handler" />
        </type>
      </assembly>
    </linker>
    

    【讨论】:

    • 我在过去的一年中尝试了基于 LinkDescription 文件的解决方案,但它们从未奏效。我花了几个小时和他们在一起。我可能遗漏了一些东西......文档可能应该有一个演示解决方案,一个项目没有显示崩溃的 LinkDescription 文件,另一个项目显示它的 LinkDescription 文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多