Xamarin.iOS UITest does not run with category - visual-studio

I have a lot of uitests for Xamarin.Forms app. These tests under categories. (For example LoginTest category has 10 tests, InboxTest category has 40 tests etc.) When I select 1 category (or when I select more than categories) and run it on iOS simulator, firstly tests of these categories runs, but after a while some tests don't run.
And I encounter this error:
Connection closed
Stack trace:
at MonoDevelop.Core.Execution.RemoteProcessConnection.SendMessage[RT] (MonoDevelop.Core.Execution.BinaryMessage`1[RT] message) [0x00024] in /Users/builder/azdo/_work/1/s/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/RemoteProcessConnection.cs:374
at MonoDevelop.UnitTesting.NUnit.External.ExternalTestRunner.Run (MonoDevelop.UnitTesting.NUnit.External.IRemoteEventListener listener, System.String[] nameFilter, System.String path, System.String suiteName, System.Collections.Generic.List`1[T] supportAssemblies, System.String testRunnerType, System.String testRunnerAssembly, System.String crashLogFile) [0x00099] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs:91
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread () [0x001b6] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTask.cs:916
at Microsoft.VisualStudio.Threading.JoinableTask`1[T].CompleteOnCurrentThread () [0x00000] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTask`1.cs:84
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T] (System.Func`1[TResult] asyncMethod, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions) [0x0000e] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTaskFactory.cs:505
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T] (System.Func`1[TResult] asyncMethod) [0x00000] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTaskFactory.cs:484
at MonoDevelop.UnitTesting.NUnit.NUnitAssemblyTestSuite.RunUnitTest (MonoDevelop.UnitTesting.UnitTest test, System.String suiteName, System.String pathName, System.String testName, MonoDevelop.UnitTesting.TestContext testContext) [0x00265] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitAssemblyTestSuite.cs:535
at MonoDevelop.UnitTesting.NUnit.NUnitTestSuite.OnRun (MonoDevelop.UnitTesting.TestContext testContext) [0x00000] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestSuite.cs:79
at MonoDevelop.UnitTesting.UnitTest.Run (MonoDevelop.UnitTesting.TestContext testContext) [0x0001c] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTest.cs:351
When I run it one by one, they run.
My Visual Studio mac version is 8.8.4 (up to date)
Xamarin.TestCloud.Agent version is 0.22.1
Xamarin.UITest version is 3.0.12
What must I do?
Thank you in advance.

Related

Can't resolve Prism DryIoc Forms IModuleCatalog

I am having a weird issue with the entry point of my app in App.xaml.cs when an interface is being resolved by Prism MVVM.
public App(IPlatformIniializer initializer) : base(initializer) {}
Stack Trace
The issue I am having does not stem from my code (at least I can't see so) so here is the stack trace as I do not know what to post, and I can't post my entire project here.
The error starts in CreateFormsApp() as the trace shows, the line is var app = new App(new AndroidInitializer());
And then from there, it goes into Prisms library code. I had a look at their source code and I can see it on like 150 of this.
When IModuleCatalog is being resolved it throws an error, I don't know how I can fix something like this.
Has anyone encountered this before?
at Prism.DryIoc.DryIocContainerExtension.Resolve (System.Type type, System.ValueTuple`2[System.Type,System.Object][] parameters) [0x00053] in /_/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs:298
at Prism.DryIoc.DryIocContainerExtension.Resolve (System.Type type) [0x00000] in /_/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs:272
at Prism.Ioc.IContainerProviderExtensions.Resolve[T] (Prism.Ioc.IContainerProvider provider) [0x00000] in /_/src/Prism.Core/Ioc/IContainerProviderExtensions.cs:18
at Prism.PrismApplicationBase.Initialize () [0x00057] in /_/src/Forms/Prism.Forms/PrismApplicationBase.cs:150
at Prism.PrismApplicationBase.InitializeInternal () [0x00006] in /_/src/Forms/Prism.Forms/PrismApplicationBase.cs:94
at Prism.PrismApplicationBase..ctor (Prism.IPlatformInitializer platformInitializer) [0x00031] in /_/src/Forms/Prism.Forms/PrismApplicationBase.cs:72
at Prism.DryIoc.PrismApplication..ctor (Prism.IPlatformInitializer platformInitializer) [0x00000] in /_/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs:25
at MyApp.App..ctor (Prism.IPlatformInitializer initializer) [0x00000] in C:\Users\Steve\source\repos\MyApp\MyApp\App.xaml.cs:50
at MyApp.Droid.MainActivity.CreateFormsApp (Android.OS.Bundle bundle) [0x0021e] in C:\Users\Steve\source\repos\MyApp\MyApp.Android\MainActivity.cs:226

Android app crashes right away after being downloaded from google play store

I have created a Android app which runs perfectly fine when I debug it in Visual Studio 2019 on my Android phone.
But when I publish it to the Google Store and download it and run it on the same phone it crashes right away.
The stack trace is:
android.runtime.JavaProxyThrowable: at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) <0x7e57beb580 + 0x006f0> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) <0x7e57be9354 + 0x00053> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.ResolveInternal (FreshTinyIoC.FreshTinyIoCContainer+TypeRegistration registration, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) <0x7e57beade0 + 0x006ff> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.Resolve (System.Type resolveType) <0x7e57be85d4 + 0x00083> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.Resolve[ResolveType] () <0x7e57be8668 + 0x0003b> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshMvvm.FreshTinyIOCBuiltIn.Resolve[ResolveType] () <0x7e57b810c0 + 0x00047> in <d2b205c381d14059b4260d7482e68c02>:0
at FreshMvvm.FreshPageModelResolver.ResolvePageModel[T] (System.Object initData) <0x7e57b80c90 + 0x00057> in <d2b205c381d14059b4260d7482e68c02>:0
at FreshMvvm.FreshPageModelResolver.ResolvePageModel[T] () <0x7e57b80c54 + 0x00033> in <d2b205c381d14059b4260d7482e68c02>:0
at GoTexas.App.InitNavigation () <0x7e57b426f4 + 0x00037> in <dd7679dd949e46e680e37995753481d2>:0
at GoTexas.App..ctor () <0x7e57b42600 + 0x0009f> in <dd7679dd949e46e680e37995753481d2>:0
at GoTexas.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) <0x7e54f0b75c + 0x0010f> in <a02812a7c00f4c1c87e549cce19fa824>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) <0x7e598ad064 + 0x0007b> in <899f47c5cea3409e92f041348b58600b>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr,intptr)
at md5b9bd3a38d4378f5ce9f0aa132dfd154f.MainActivity.n_onCreate (Native Method)
at md5b9bd3a38d4378f5ce9f0aa132dfd154f.MainActivity.onCreate (30)
at android.app.Activity.performCreate (Activity.java:7327)
at android.app.Activity.performCreate (Activity.java:7318)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3094)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3257)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1948)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7050)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:964)
So it has something to do with FreshTinyIoC. I just don't get why this works when running off VS 2019 in debug mode off my phone.
Any ideas would be greatly appreciated.
The issue is quite simple actually you have set linking to SDK & User Assemblies which means it is linking everything, your models and every other class, anything that does not have a reference will be collected and removed for better understanding you can check my blog which has an entire section on how to work with Linking:
https://heartbeat.fritz.ai/reducing-the-app-size-in-xamarin-deep-dive-7ddc9cb12688
As of now, I would suggest you can check Link SDK Assemblies for now and then you can Link everything as that takes a little time
Goodluck, Feel free to get back in case of queries

Xamarin.Forms - MONO_GC_PARAMS=bridge-implementation=old - how to tell if it's working on Windows?

I'm seeing this cryptic exception that's been documented on bugzilla.xamarin.com periodically. Most of the posts suggest you can suppress the error by changing the bridge implementation to the Old version instead of Tarjan by setting an environment variable:
MONO_GC_PARAMS=bridge-implementation=old
I set the variable, but I don't see anything in my logcat or build output to indicate it's using one bridge or the other, and I'm still getting the exception. Is there a way to tell which implementation is being used?
Here's the stack trace - any suggestions are greatly appreciated.
Process: com.icon.iconsurvey, PID: 11543
android.runtime.JavaProxyThrowable: System.ArgumentException: Handle must be valid.
Parameter name: instance
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00009] in <7cfbebb561c54efc9010b018c0846c7e>:0
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00015] in <e975227ac8644a30bb0866117325de0d>:0
at Android.Support.V4.Widget.DrawerLayout.RemoveDrawerListener (Android.Support.V4.Widget.DrawerLayout+IDrawerListener listener) [0x00088] in <fc4222de5c684a9abf7cc4821baac4cd>:0
at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.Dispose (System.Boolean disposing) [0x000e4] in <b5b1173f4d49442b898c45e26ae39e48>:0
at Java.Lang.Object.Dispose () [0x00000] in <e975227ac8644a30bb0866117325de0d>:0
at Xamarin.Forms.Platform.Android.AppCompat.Platform+<>c__DisplayClass35_0.<SetPage>b__0 () [0x00015] in <b5b1173f4d49442b898c45e26ae39e48>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <e975227ac8644a30bb0866117325de0d>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <e975227ac8644a30bb0866117325de0d>:0
at (wrapper dynamic-method) System.Object:1d7dae73-d3c1-4d29-aa82-708ecaa93ad1 (intptr,intptr)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6939)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
The current suggestion is using new rather than old when changing the default GC Bridge away from tarjan. You may have been told to use the "old" default which was technically new before changing to tarjan in Mono 4.6:
http://www.mono-project.com/docs/about-mono/releases/4.6.0/#new-default-gc-bridge-processor-on-android
You can see if this is being picked up by checking the Diagnostic Build Output of your project.
https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Diagnostic_MSBuild_Output
You would then look to ensure the configuration file is picked up with the respective arguments.

How to read linker error in Xamarin

I get the following error while executing my Xamarin Android app in release mode. I suppose something is missing in LinkerPleaseInclude.cs, but the error message is not very helpful.
09-25 16:17:38.140 W/art ( 1082): JNI RegisterNativeMethods: attempt to register 0 native methods for mvvmcross.binding.droid.views.MvxRadioGroup
[0:] MvxBind:Error: 2,89 Exception thrown during the view binding ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (Android.Widget.TextView source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00017] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (Android.Widget.TextView source, System.String sourceEventName, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00012] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe[TSource,TEventArgs] (TSource source, System.String eventName, System.EventHandler`1[TEventArgs] eventHandler) [0x00000] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.Binding.Droid.Target.MvxTextViewTextTargetBinding.SubscribeToEvents () [0x0000b] in <cc9453c0f5794d529a8b1975bb62dd40>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00057] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x0002f] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00018] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at System.Linq.Utilities+<>c__DisplayClass2_0`3[TSource,TMiddle,TResult].<CombineSelectors>b__0 (TSource x) [0x00012] in <9ecdeee51aa740839577d6db9550e95f>:0
at System.Linq.Utilities+<>c__DisplayClass2_0`3[TSource,TMiddle,TResult].<CombineSelectors>b__0 (TSource x) [0x00000] in <9ecdeee51aa740839577d6db9550e95f>:0
at (wrapper delegate-invoke) System.Func`2[System.Collections.Generic.KeyValuePair`2[System.String,MvvmCross.Binding.Parse.Binding.MvxSerializableBindingDescription],System.Collections.Generic.KeyValuePair`2[System.Object,MvvmCross.Binding.Bindings.IMvxUpdateableBinding]]:invoke_TResult_T (System.Collections.Generic.KeyValuePair`2<string, MvvmCross.Binding.Parse.Binding.MvxSerializableBindingDescription>)
at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00048] in <9ecdeee51aa740839577d6db9550e95f>:0
at System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) [0x000ea] in <b2855d13f99e445b95990a59348d98e8>:0
at System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) [0x00000] in <b2855d13f99e445b95990a59348d98e8>:0
at MvvmCross.Binding.Droid.Binders.MvxAndroidViewBinder.StoreBindings (Android.Views.View view, System.Collections.Generic.IEnumerable`1[T] newBindings) [0x00028] in <cc9453c0f5794d529a8b1975bb62dd40>:0
at MvvmCross.Binding.Droid.Binders.MvxAndroidViewBinder.ApplyBindingsFromAttribute (Android.Views.View view, Android.Content.Res.TypedArray typedArray, System.Int32 attributeId) [0x0001c] in <cc9453c0f5794d529a8b1975bb62dd40>:0
I see, something is missing with MvxRadioGroup. How do I find out what to add in LinkerPleaseInclude?
My binding for MvxRadioGroup is the following:
<MvxRadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="6dp"
local:MvxBind="ItemsSource GenderAnswers; SelectedItem GenderAnswer"
local:MvxItemTemplate="#layout/radioitem_enum" />
and my LinkerPleaseInclude is still empty.
Here's the defintiion of the properties in view model:
public IEnumerable<GenderQuestionAnswers> GenderAnswers => Enum.GetValues(typeof(GenderQuestionAnswers)).Cast<GenderQuestionAnswers>();
public GenderQuestionAnswers? GenderAnswer
{
get => _genderAnswer;
set => SetProperty(ref _genderAnswer, value);
}
[edit 2017-09-27]: added code for MvxRadioGroup binding
[edit 2017-09-27]: added snippet for properties in view model
I ended up adding theses lines to LinkerPleaseInclude in addition to the file mentioned by #york-shen-msft
public void Include(RadioButton radioButton)
{
radioButton.CheckedChange += (sender, args) => radioButton.Checked = args.IsChecked
}
Well, that doesn't really answer my question as I wanted to know how to find the correct solution without searching the whole internet for lines others included before and do trial and error, but it solves my actual problem for the moment.

parse.com query throws stack overflow exception under mono

I am building a simple C# mono application that queries data from parse.com server.
Nothing special:
private static async Task<ParseGameData> DownloadGameData(DateTime dateFrom)
{
ParseGameData gameData = new ParseGameData();
InitParse();
var qHits = ParseObject.GetQuery("Hits").WhereGreaterThan("createdAt", dateFrom)
.Limit(100).OrderBy("createdAt");
gameData.hits = await qHits.FindAsync();
return gameData;
}
And called from another function:
ParseGameData gameData = DownloadGameData(timestamp).Result;
This works great and no exception is being thrown when querying small amount (~less than 75 records). But if I set the limit higher, application crashes and I get this:
Unhandled Exception:
System.StackOverflowException: The requested operation caused a stack overflow.
at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task`1[System.Threading.Tasks.TaskExtensions+VoidResult].TrySetResult (VoidResult result) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.UnwrapPromise`1[System.Threading.Tasks.TaskExtensions+VoidResult].TrySetFromTask (System.Threading.Tasks.Task task, Boolean lookForOce) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.UnwrapPromise`1[System.Threading.Tasks.TaskExtensions+VoidResult].InvokeCore (System.Threading.Tasks.Task completingTask) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.UnwrapPromise`1[System.Threading.Tasks.TaskExtensions+VoidResult].Invoke (System.Threading.Tasks.Task completingTask) [0x00000] in <filename unknown>:0
... and then these lines repeat.
For interest purposes: each record in database takes about ~65KB, so a 100 hits would be 6.5MB.
I've tried this code on two mono platforms, on OS X and Linux. Both platforms throw stackoverflow exceptions. However on Windows, using .NET, it works fine, even with 1000 limit. That leads me to believe it is something with mono and parse.com libraries. Any suggestions?
It seems like it was a parse library bug. I have downgraded parse lib from 1.5.5 to 1.5.4 and now it works fine.

Resources