问题
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