Xamarin Android 应用程序在发布模式下崩溃 (Parse.Android SDK) [英] Xamarin Android app crash in Release mode (Parse.Android SDK)

查看:24
本文介绍了Xamarin Android 应用程序在发布模式下崩溃 (Parse.Android SDK)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用 Parse Android SDK 的应用程序.应用程序在调试模式下正常工作,但是当我在发布模式下编译它时,出现以下错误.执行解析查询时发生错误.不是在我初始化解析时.

I am developing app which uses Parse Android SDK. App is working properly in debug mode but when i compile it on release mode i get following errors. Error occur when parse query is executed. Not when i initialize parse.

[MonoDroid] UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
[MonoDroid]   at Parse.PlatformHooks+<RequestAsync>d__19.MoveNext () [0x00000] in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
[MonoDroid]   at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.TaskActionInvoker+FuncTaskInvoke`1[System.Threading.Tasks.Task`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]]].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
[MonoDroid]   at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Collections.Generic.IEnumerable`1[Parse.ParseObject]].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.TaskActionInvoker+FuncTaskInvoke`1[System.Threading.Tasks.Task`1[System.Collections.Generic.IEnumerable`1[Parse.ParseObject]]].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[System.Collections.Generic.IEnumerable`1[Parse.ParseObject]].GetResult () [0x00000] in <filename unknown>:0 
[MonoDroid]   at ParseDAL.ParseCaller+<Init>c__async0.MoveNext () [0x00000] in <filename unknown>:0 
[mono] 
[mono] Unhandled Exception:
[mono] System.NullReferenceException: Object reference not set to an instance of an object
[mono]   at Parse.PlatformHooks+<RequestAsync>d__19.MoveNext () [0x00000] in <filename unknown>:0 
[mono] --- End of stack trace from previous location where exception was thrown ---
[mono]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
[mono]   at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 
[mono]   at System.Threading.Tasks.TaskActionInvoker+FuncTaskInvoke`1[System.Threading.Tasks.Task`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]]].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
[mono]   at System.Threading.Tasks.Task.InnerInvoke 
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
[mono-rt]   at Parse.PlatformHooks+<RequestAsync>d__19.MoveNext () [0x00000] in <filename unknown>:0 
[mono-rt] --- End of stack trace from previous location where exception was thrown ---
[mono-rt]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
[mono-rt]   at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 
[mono-rt]   at System.Threading.Tasks.TaskActionInvoker+FuncTaskInvoke`1[System.Threading.Tasks.Task`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]]].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
[mono-rt]   at System.Threading.Tasks.Task

代码如下:

ParseClient.Initialize("App Id", "Dot Net Key");
var userQuery = ParseObject.GetQuery ("Table Name");
var userData = await userQuery.FindAsync ();
foreach (var ud in userData) {
    Console.WriteLine ("UD " + ud.Get<string>(Constants.COL_USER_NAME));
}

我尝试了所有链接器选项不链接"、链接所有程序集"、链接 SDK 程序集".但应用仍然崩溃.

I tried with all linker option "Dont Link", "Link All Assemblies", "Link SDK assemblies". But app is still crashing.

推荐答案

出现此异常是因为网络问题而不是因为调试/发布版本.在调试模式下,INTERNET 权限会自动添加到清单文件中,但在发布模式下不会.所以在清单文件中添加这个权限.

This exception occur because of network issue not because of debug/release build. In debug mode INTERNET permission is automatically added in manifest file, but not in release mode. So add this permission in manifest file.

<uses-permission android:name="android.permission.INTERNET" />

此异常在release模式下不会发生.

after this exception will not occur in release mode.

在发送解析请求之前,我们仍然需要检查网络是否可用.

We still need to check that network is available or not before sending request to parse.

这篇关于Xamarin Android 应用程序在发布模式下崩溃 (Parse.Android SDK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆