Xamarin Android 12 - 初始崩溃
Xamarin Android 12 - Initial Crash
我刚刚开发了我的 Xamarin Forms 应用程序并发布了 iOS 的下一个版本。
然后我回到 Android 版本,假设它会很好地工作(因为 android 一直为我做的)。
现在是这样:
[QXPerf] Couldn't load BLASTBufferQueue Class
[QXPerf] Couldn't find UndequeuedBufferCount functions
[Looper] PerfMonitor longMsg : seq=4 plan=10:19:09.074 late=5792ms wall=2177ms running=0ms h=android.app.ActivityThread$H w=159 procState=-1
[Looper] PerfMonitor looperActivity : package=de.myapp.app/crc643873299c977c4ba1.MainActivity time=2177ms latency=5792ms running=0ms procState=-1 historyMsgCount=1 (msgIndex=1 wall=5790ms seq=3 late=1ms h=android.app.ActivityThread$H w=110)
[Looper] PerfMonitor looperActivity : package=de.myapp.app/crc643873299c977c4ba1.MainActivity time=0ms latency=7970ms running=0ms procState=-1 historyMsgCount=2 (msgIndex=1 wall=5790ms seq=3 late=1ms h=android.app.ActivityThread$H w=110) (msgIndex=2 wall=2177ms seq=4 late=5792ms h=android.app.ActivityThread$H w=159)
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
[MIUIScout App] Enter APP_SCOUT_WARNING State
[MIUIScout App] Event:APP_SCOUT_WARNING Thread:main backtrace:
[MIUIScout App] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[MIUIScout App] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[MIUIScout App] at android.os.Handler.handleCallback(Handler.java:938)
[MIUIScout App] at android.os.Handler.dispatchMessage(Handler.java:99)
[MIUIScout App] at android.os.Looper.loopOnce(Looper.java:210)
[MIUIScout App] at android.os.Looper.loop(Looper.java:299)
[MIUIScout App] at android.app.ActivityThread.main(ActivityThread.java:8085)
[MIUIScout App] at java.lang.reflect.Method.invoke(Native Method)
[MIUIScout App] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
[MIUIScout App] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
[MIUIScout App] Enter APP_SCOUT_HANG state
[MIUIScout App] Event:APP_SCOUT_HANG Thread:main backtrace:
[MIUIScout App] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[MIUIScout App] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[MIUIScout App] at android.os.Handler.handleCallback(Handler.java:938)
[MIUIScout App] at android.os.Handler.dispatchMessage(Handler.java:99)
[MIUIScout App] at android.os.Looper.loopOnce(Looper.java:210)
[MIUIScout App] at android.os.Looper.loop(Looper.java:299)
[MIUIScout App] at android.app.ActivityThread.main(ActivityThread.java:8085)
[MIUIScout App] at java.lang.reflect.Method.invoke(Native Method)
[MIUIScout App] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
[MIUIScout App] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
我完全不知道这是从哪里来的,也不知道我该如何绕过它。
有人知道该怎么做吗?
你好莫里斯
问题是由使用 Xamarin.Essentials.Preferences.Get("Key", false);
的转换引起的
用 try{ }catch(Exception e)
包围它可以让应用程序作为请求启动。
Try catch
没有解决问题,它只是停止崩溃。
Xamarin.Essentials.Preferences
在 Android 12 中似乎有问题,请在此处查看问题:https://github.com/xamarin/Essentials/issues/1991 .
为此,您可以寻求另一种方法来替换 Preferences
,或者自己实现 Shared Preferences。
我刚刚开发了我的 Xamarin Forms 应用程序并发布了 iOS 的下一个版本。 然后我回到 Android 版本,假设它会很好地工作(因为 android 一直为我做的)。
现在是这样:
[QXPerf] Couldn't load BLASTBufferQueue Class
[QXPerf] Couldn't find UndequeuedBufferCount functions
[Looper] PerfMonitor longMsg : seq=4 plan=10:19:09.074 late=5792ms wall=2177ms running=0ms h=android.app.ActivityThread$H w=159 procState=-1
[Looper] PerfMonitor looperActivity : package=de.myapp.app/crc643873299c977c4ba1.MainActivity time=2177ms latency=5792ms running=0ms procState=-1 historyMsgCount=1 (msgIndex=1 wall=5790ms seq=3 late=1ms h=android.app.ActivityThread$H w=110)
[Looper] PerfMonitor looperActivity : package=de.myapp.app/crc643873299c977c4ba1.MainActivity time=0ms latency=7970ms running=0ms procState=-1 historyMsgCount=2 (msgIndex=1 wall=5790ms seq=3 late=1ms h=android.app.ActivityThread$H w=110) (msgIndex=2 wall=2177ms seq=4 late=5792ms h=android.app.ActivityThread$H w=159)
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
[MIUIScout App] Enter APP_SCOUT_WARNING State
[MIUIScout App] Event:APP_SCOUT_WARNING Thread:main backtrace:
[MIUIScout App] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[MIUIScout App] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[MIUIScout App] at android.os.Handler.handleCallback(Handler.java:938)
[MIUIScout App] at android.os.Handler.dispatchMessage(Handler.java:99)
[MIUIScout App] at android.os.Looper.loopOnce(Looper.java:210)
[MIUIScout App] at android.os.Looper.loop(Looper.java:299)
[MIUIScout App] at android.app.ActivityThread.main(ActivityThread.java:8085)
[MIUIScout App] at java.lang.reflect.Method.invoke(Native Method)
[MIUIScout App] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
[MIUIScout App] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
[MIUIScout App] Enter APP_SCOUT_HANG state
[MIUIScout App] Event:APP_SCOUT_HANG Thread:main backtrace:
[MIUIScout App] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[MIUIScout App] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[MIUIScout App] at android.os.Handler.handleCallback(Handler.java:938)
[MIUIScout App] at android.os.Handler.dispatchMessage(Handler.java:99)
[MIUIScout App] at android.os.Looper.loopOnce(Looper.java:210)
[MIUIScout App] at android.os.Looper.loop(Looper.java:299)
[MIUIScout App] at android.app.ActivityThread.main(ActivityThread.java:8085)
[MIUIScout App] at java.lang.reflect.Method.invoke(Native Method)
[MIUIScout App] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
[MIUIScout App] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
我完全不知道这是从哪里来的,也不知道我该如何绕过它。
有人知道该怎么做吗?
你好莫里斯
问题是由使用 Xamarin.Essentials.Preferences.Get("Key", false);
用 try{ }catch(Exception e)
包围它可以让应用程序作为请求启动。
Try catch
没有解决问题,它只是停止崩溃。
Xamarin.Essentials.Preferences
在 Android 12 中似乎有问题,请在此处查看问题:https://github.com/xamarin/Essentials/issues/1991 .
为此,您可以寻求另一种方法来替换 Preferences
,或者自己实现 Shared Preferences。