Xamarin Android App Launched in Release Mode (Parse.Android SDK)

I am developing an application that uses the Parse Android SDK. The application works correctly in debug mode, but when I compile it in release mode, I get the following errors. An error occurred while executing the analysis request. Not when I initialize the parsing.

[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 

Below is the code:

 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)); } 

I tried using all the options of the linker "Dont Link", "Link All Assemblies", "Link SDK assemblylies". But the application is still crashing.

+6
source share
1 answer

This exception is due to network issues not due to the debug / release build. In debug mode, the INTERNET permission is automatically added to the manifest file, but not in release mode. Therefore, add this permission to the manifest file.

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

after this exception does not occur in release mode.

We still need to check if the network is available or not, before sending a request for analysis.

+13
source

Source: https://habr.com/ru/post/969846/


All Articles