随机System.ArgumentException:'jobject'不能为IntPtr.Zero [英] Random System.ArgumentException: 'jobject' must not be IntPtr.Zero
问题描述
我们在Android上使用Xamarin随机生成了System.ArgumentException
.它是完全随机的-它可以在任何平台上随时随地发生.我们在5.1、5.0、4.4.4上进行了注册.
We have random System.ArgumentException
with Xamarin on android. It is completely random - it can occur anytime and anywhere, on any platform. We registered it on 5.1, 5.0, 4.4.4.
它没有足够的堆栈跟踪,也没有放置它的地方,我什么都抓不到.我认为这可能与async void
有关,我们在项目中使用了MVVMCross,并且有很多async void Init
和async void DoMvxCommand
方法.但是所有这些都包含在try-catch块中.
It has no adequate stacktrace, it has no place where it thrown, I can't catch it with anything. I think it might be somehow related to async void
, we use MVVMCross in the project and there are many async void Init
and async void DoMvxCommand
methods. But all of them enclosed in try-catch blocks.
我非常需要任何建议来解决或至少找到此崩溃的原因.这是最新的崩溃日志
I crucially need any advice how to fix or at least find the reason of this crash. Here is the latest crash log
undefined INFO: ActivityManager : Displayed com.website.app/md599d9a15f782f9118e8e70c354562b227.SuccessPaymentView: +220ms
undefined WARN: ContextImpl : Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1629 com.android.server.InputMethodManagerService$6.run:2728 java.lang.Thread.run:818 <bottom of call stack> <bottom of call stack>
undefined WARN: ActivityManager : mDVFSHelper.release()
undefined INFO: Timeline : Timeline: Activity_windows_visible id: ActivityRecord{1aca0d50 u0 com.website.app/md599d9a15f782f9118e8e70c354562b227.SuccessPaymentView t5672} time:169720248
undefined INFO: MonoDroid : UNHANDLED EXCEPTION:
undefined INFO: MonoDroid : System.ArgumentException: 'jobject' must not be IntPtr.Zero.
undefined INFO: MonoDroid : Parameter name: jobject
undefined INFO: MonoDroid : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
undefined INFO: MonoDroid : at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <0x0003f>
undefined INFO: MonoDroid : at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () <0x00027>
undefined INFO: MonoDroid : at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
undefined INFO: MonoDroid : at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>
undefined INFO: MonoDroid : at (wrapper dynamic-method) object.81971695-c4eb-4dd7-9e27-0dec45822877 (intptr,intptr) <0x0003b>
undefined DEBUG: LockPatternUtilsCache : getCarrierLockPlusMode()
undefined DEBUG: LockPatternUtilsCache : value : false
undefined WARN: Xamarin.Insights : Warning: Unhandled exception: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
undefined WARN: Xamarin.Insights : Parameter name: jobject
undefined WARN: Xamarin.Insights : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
undefined WARN: Xamarin.Insights : at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <0x0003f>
undefined WARN: Xamarin.Insights : at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () <0x00027>
undefined WARN: Xamarin.Insights : at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
undefined WARN: Xamarin.Insights : at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>
undefined WARN: Xamarin.Insights : at (wrapper dynamic-method) object.81971695-c4eb-4dd7-9e27-0dec45822877 (intptr,intptr) <0x0003b>
undefined WARN: art : JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
undefined DEBUG: AndroidRuntime : Shutting down VM
undefined WARN: System.err : java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
undefined WARN: System.err : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
undefined WARN: System.err : Caused by: java.lang.reflect.InvocationTargetException
undefined WARN: System.err : at java.lang.reflect.Method.invoke(Native Method)
undefined WARN: System.err : at java.lang.reflect.Method.invoke(Method.java:372)
undefined WARN: System.err : at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
undefined WARN: System.err : ... 1 more
undefined WARN: System.err : Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
undefined WARN: System.err : Parameter name: jobject
undefined WARN: System.err : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
undefined WARN: System.err : at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <0x0003f>
undefined WARN: System.err : at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () <0x00027>
undefined WARN: System.err : at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
undefined WARN: System.err : at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>
undefined WARN: System.err : at (wrapper dynamic-method) object.81971695-c4eb-4dd7-9e27-0dec45822877 (intptr,intptr) <0x0003b>
undefined WARN: System.err : at mono.java.lang.RunnableImplementor.n_run(Native Method)
undefined WARN: System.err : at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
undefined WARN: System.err : at android.os.Handler.handleCallback(Handler.java:739)
undefined WARN: System.err : at android.os.Handler.dispatchMessage(Handler.java:95)
undefined WARN: System.err : at android.os.Looper.loop(Looper.java:145)
undefined WARN: System.err : at android.app.ActivityThread.main(ActivityThread.java:5832)
undefined WARN: System.err : ... 4 more
undefined WARN: FlurryAgent : Error logged: uncaught
undefined WARN: FlurryAgent : Flurry session ended
undefined ERROR: AndroidRuntime : FATAL EXCEPTION: main
undefined ERROR: AndroidRuntime : Process: com.website.app, PID: 27622
undefined ERROR: AndroidRuntime : java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
undefined ERROR: AndroidRuntime : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
undefined ERROR: AndroidRuntime : Caused by: java.lang.reflect.InvocationTargetException
undefined ERROR: AndroidRuntime : at java.lang.reflect.Method.invoke(Native Method)
undefined ERROR: AndroidRuntime : at java.lang.reflect.Method.invoke(Method.java:372)
undefined ERROR: AndroidRuntime : at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
undefined ERROR: AndroidRuntime : ... 1 more
undefined ERROR: AndroidRuntime : Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
undefined ERROR: AndroidRuntime : Parameter name: jobject
undefined ERROR: AndroidRuntime : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
undefined ERROR: AndroidRuntime : at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <0x0003f>
undefined ERROR: AndroidRuntime : at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () <0x00027>
undefined ERROR: AndroidRuntime : at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
undefined ERROR: AndroidRuntime : at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>
undefined ERROR: AndroidRuntime : at (wrapper dynamic-method) object.81971695-c4eb-4dd7-9e27-0dec45822877 (intptr,intptr) <0x0003b>
undefined ERROR: AndroidRuntime : at mono.java.lang.RunnableImplementor.n_run(Native Method)
undefined ERROR: AndroidRuntime : at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
undefined ERROR: AndroidRuntime : at android.os.Handler.handleCallback(Handler.java:739)
undefined ERROR: AndroidRuntime : at android.os.Handler.dispatchMessage(Handler.java:95)
undefined ERROR: AndroidRuntime : at android.os.Looper.loop(Looper.java:145)
undefined ERROR: AndroidRuntime : at android.app.ActivityThread.main(ActivityThread.java:5832)
undefined ERROR: AndroidRuntime : ... 4 more
undefined WARN: ActivityManager : Force finishing activity com.website.app/md599d9a15f782f9118e8e70c354562b227.SuccessPaymentView
undefined DEBUG: PowerManagerService : [input device light] setInputDeviceLightOn is called : 1
undefined WARN: ActivityManager : Force finishing activity com.website.app/md599d9a15f782f9118e8e70c354562b227.PaymentFormView
undefined INFO: SQLiteSecureOpenHelper : getWritableDatabase(pwd)
undefined INFO: SQLiteSecureOpenHelper : getDatabaseLocked(b,b,pwd)...
undefined INFO: dumpstate : begin
undefined DEBUG: StatusBarManagerService : manageDisableList userId=0 what=0x0 pkg=WindowManager.LayoutParams
undefined INFO: SurfaceFlinger : id=3018 createSurf (49x49),1 flag=4, Application Error: com.website.app
undefined DEBUG: CrashAnrDetector : processName: com.website.app
undefined DEBUG: CrashAnrDetector : broadcastEvent : com.website.app data_app_crash
undefined INFO: SQLiteSecureOpenHelper : getWritableDatabase(pwd)
undefined INFO: SQLiteSecureOpenHelper : getDatabaseLocked(b,b,pwd)...
undefined WARN: ContextImpl : Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1643 com.android.server.analytics.data.collection.application.CrashAnrDetector.broadcastEvent:296 com.android.server.analytics.data.collection.application.CrashAnrDetector.processDropBoxEntry:254 com.android.server.analytics.data.collection.application.CrashAnrDetector.access$100:60 com.android.server.analytics.data.collection.application.CrashAnrDetector$1.onReceive:102
undefined INFO: WifiStateMachine : CMD_RSSI_POLL : calculateWifiScore in!
undefined INFO: WifiStateMachine : CMD_RSSI_POLL : calculateWifiScore out!
undefined INFO: WifiStateMachine : CMD_RSSI_POLL : out!
undefined ERROR: android.os.Debug : !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
推荐答案
我遇到了一个非常相似的问题,即Android似乎随机抛出了NullRefenceException
(这实际上是因为事情是异步/并行运行的),并且它们永远不会中断正确的位置,而StackTrace完全一文不值.请在此处中查看线程和解决方案.
I had a very similar issue with Android throwing NullRefenceException
s seemingly randomly (which was actually because things were running asynchronously/concurrently) and they would never break at the correct spot and the StackTrace was completely worthless. See the thread and solution here.
无论如何,解决方案的2个部分让我弄清楚了这个问题:
Anyway, 2 parts of the solution that allowed me to figure out the issue were:
- 打开Visual Studio中的设置以中断/抛出特定异常.为此,请转到此帖子.帖子描述了转到Visual Studio->调试->异常...(或
Ctrl
+Alt
+E
)
- Turn on the setting in Visual Studio in order to break/throw on the specific exception. To do this, head to this post. The post describes going to Visual Studio -> Debug -> Exceptions... (or
Ctrl
+Alt
+E
)
然后,要查找该异常,请展开公共语言运行时异常"->系统"->,然后选中"System.ArgumentException"旁边的引发"框.希望现在它将中断实际发生该异常的行.同样,一旦问题解决,您肯定会希望将其关闭,以免遇到不必要的异常.
Then, to find that exception, expand 'Common Language Runtime Exceptions' -> 'System' -> then check the 'Thrown' box next 'System.ArgumentException'. Now it will, hopefully, break on the line where that exception actually happens. Also you will definitely want to turn this off once the issue has been fixed so that you do not start hitting exceptions that you do not really need to handle.
- 覆盖称为
UnhandledExceptionRaiser
的Android异常处理程序事件,然后在该事件内设置一个断点,以帮助您在应用崩溃之前捕获其中的某些异常.可以在此帖子中找到该事件的信息(我最后只是把那个事件进入MainActivity.cs
.
- Override Android's exception handler event, called
UnhandledExceptionRaiser
, and then set a breakpoint within the event in order to help you catch some of these exceptions before your app crashes. The event info can be found in this post (I ended up just putting that event intoMainActivity.cs
.
这是我的异常事件代码:
Here is my exception event code:
AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) => {
args.Handled = false;
};
我只是在args.Handled
上设置了一个断点,并仔细查看了细节,但是您也可以打印出异常或其他内容.
I just put a break point on args.Handled
and look through the details but you could also print out the exception or something.
- 最后,我自己发现但又听到其他人提到的另一件事是,您通常可以通过深入研究异常详细信息并找到
captured_traces
来找到更有用的异常源信息.
- Finally, one more thing that I found on my own but have heard others mention, is that you can usually find more helpful exception source info by digging into the exception details and finding
captured_traces
.
要找到此消息,您需要在异常详细信息"窗口中继续扩展异常实例的base
属性,直到进入System.Exception
.然后执行以下步骤(尽管有时您必须先执行内部异常操作,然后再执行以下步骤):
To find this, you need to keep expanding the exception instance's base
property, in the exception details window, until you are in System.Exception
. Then follow the steps below (though sometimes you have to go into the inner exception before following the below steps):
System.Exception
-> Non-public members
-> captured_traces
->然后您通常需要[0]
,但有时还有其他内容可以浏览-> Non-public members
-> frames
->现在您通常都想要[0]
或您想要列表中的最后一个-> Non-public members
->,最后您将能够在fileName
属性中看到文件,并在'lineNumber'属性中看到行号(想象一下).
System.Exception
-> Non-public members
-> captured_traces
-> then you usually want [0]
but sometimes there are others to look through -> Non-public members
-> frames
-> now you usually either want [0]
or you want the last one in the list -> Non-public members
-> and finally you will be able to see the file in the fileName
property and the line number in the 'lineNumber' property (imagine that).
现在,我确定有一种花哨的方法可以通过反射或其他方式提取此信息,而无需深入研究异常详细信息.如果有人知道怎么做,我很想听听!
Now I am sure there is a fancy way to extract this info with reflection or something without digging through the exception details. If anyone knowns how, I would love to hear it!
这篇关于随机System.ArgumentException:'jobject'不能为IntPtr.Zero的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!