MVVMCross Android 10.0 (Q) MainActivity exception crash on SetContentView()

喜夏-厌秋 提交于 2020-01-06 05:16:24

问题


One of the massive projects I am helping with, uses MvvmCross v5.2.1. When we target the framework Android 10.0 (API Level 29) (Q), as soon as the OnCreate() lifecycle function of the MainActivity runs, an exception crash happens on the line SetContentView(Resource.Layout.activity_main).

A part of the exception reads

java.lang.NoSuchFieldException: No field mConstructorArgs in class Landroid/view/LayoutInflater; (declaration of 'android.view.LayoutInflater' appears in /system/framework/framework.jar!classes3.dex)
    at java.lang.Class.getDeclaredField(Native Method)
    at mvvmcross.binding.droid.views.MvxLayoutInflater_PrivateFactoryWrapper2.n_onCreateView(Native Method)
    at mvvmcross.binding.droid.views.MvxLayoutInflater_PrivateFactoryWrapper2.onCreateView(MvxLayoutInflater_PrivateFactoryWrapper2.java:32)
    at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239)
    at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)

Here's a more detailed log in this pastebin.

It seems identical to this Github issue on the MvvmCross repo: and I followed the links to this pull request.

Does that mean any one using #MVVMCross before v6.4.1, must upgrade if they want to target the framework Android 10.0? Is there any work around?


回答1:


I asked the question to the creators and maintainers of the MVVMCross framework on Twitter, as you can see in this thread. I got the following response:

You need 6.4.1. No known workarounds maybe except for copying all the necessary code to fix that layout inflater issue.

This means that the only solution to target the framework Android 10.0 and above is to update to package version 6.4.1 or up. It is a very difficult process, since among other things, it also requires updating the Solution to .NET Core 2.0 Framework.

What does that mean? As of 2019, the Android Play Store only accepts APK files that are targeting framework 8.1. So within 1.5 years, they will change the requirement to Android 10.0, by when you will need to update your nuget package as well.



来源:https://stackoverflow.com/questions/59078153/mvvmcross-android-10-0-q-mainactivity-exception-crash-on-setcontentview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!