The "VerifyTaskFailed" task failed unexpectedly in Xamarin Android - xamarin

The Xamarin Android after updating nuget packages, getting this error.
Any way solve this.
/Users/hmspl/Documents/GitHub/xamarin/packages/Xamarin.Android.Support.Annotations.28.0.0.2/build/monoandroid90/Xamarin.Android.Support.Annotations.targets(9,9):
Error MSB4018: The "VerifyVersionsTask" task failed unexpectedly.
System.TypeInitializationException: The type initializer for
'Xamarin.Android.Support.BuildTasks.NugetPackages' threw an exception.
---> System.ArgumentException: An item with the same key has already been added. Key: 28 at
System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey
key, TValue value, System.Collections.Generic.InsertionBehavior
behavior) [0x002b5] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:677
at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key,
TValue value) [0x00000] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:240
at Xamarin.Android.Support.BuildTasks.NugetPackages..cctor ()
[0x0006b] in :0 --- End of inner
exception stack trace --- at
Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute ()
[0x0009d] in :0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:810
(MSB4018) (MMHRC.Droid)

Downgrade Package version 28.0.0.2 to 28.0.0.1 , something they changed is breaking projects

Related

Unable to build Xamarin Android Application in Release Mode

I am trying to build Xamarin Forms Android App but it's not getting compiled in Release mode, while Debug works fine.
Error Detail:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5):
Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.Steps.XmlResolutionException: Failed to process XML
description: --->
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly:
'Prism.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Prism.Core, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' at Mono.Cecil.BaseAssemblyResolver.Resolve
(Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters
parameters) [0x0015e] in
/Users/builder/data/lanes/6102/8255f42f/source/monodroid/external/xamarin-android/external/mono/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs:172
at Mono.Linker.AssemblyResolver.Resolve
(Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters
parameters) [0x0005c] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope)
[0x00007] in <947dd92f52fa43c1922f96c7b9774bdc>:0 --- End of inner
exception stack trace --- at Mono.Linker.LinkContext.Resolve
(Mono.Cecil.IMetadataScope scope) [0x00030] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.ResolveFromXmlStep.GetAssembly
(Mono.Linker.LinkContext context, Mono.Cecil.AssemblyNameReference
assemblyName) [0x00000] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies
(Mono.Linker.LinkContext context, System.Xml.XPath.XPathNodeIterator
iterator) [0x00010] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.ResolveFromXmlStep.Process () [0x00037] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 --- End of inner exception
stack trace --- at Mono.Linker.Steps.ResolveFromXmlStep.Process ()
[0x000a9] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context)
[0x00010] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context)
[0x0001c] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline,
Mono.Linker.LinkContext context) [0x00000] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options,
Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context)
[0x00071] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Xamarin.Android.Tasks.LinkAssemblies.Execute
(Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x002d4] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
Xamarin.Android.Tasks.LinkAssemblies.Execute () [0x0021f] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
(MSB4018) (VSTSBuild.Droid)
Also I noticed that it's building in Release mode as well if I enable 'Use Shared Mono Runtime' but if it's disabled then I am having issue building the solution.
Okay, I found out that issue was with LinkerSettings. Previously my Linker Settings was like this:
<linker>
<assembly
fullname="Prism.Core" />
<assembly
fullname="Prism.Forms" />
<assembly
fullname="Prism.Unity.Forms" />
<assembly
fullname="Prism.Plugin.Popups" />
</linker>
Which I updated to:
<linker>
<assembly
fullname="Prism.Forms">
<type
fullname="Prism.Common.ApplicationProvider"
preserve="all" />
<type
fullname="Prism.Services.PageDialogService"
preserve="all" />
<type
fullname="Prism.Services.DeviceService"
preserve="all" />
<type
fullname="Prism.Ioc*"
preserve="all" />
<type
fullname="Prism.Modularity*"
preserve="all" />
<type
fullname="Prism.Navigation*"
preserve="all" />
<type
fullname="Prism.Behaviors.PageBehaviorFactory"
preserve="all">
<method
name=".ctor" />
</type>
<type
fullname="Prism.Services.DependencyService"
preserve="all">
<method
name=".ctor" />
</type>
</assembly>
<assembly
fullname="Prism">
<type
fullname="Prism.Navigation*"
preserve="all" />
<type
fullname="Prism.Logging.EmptyLogger"
preserve="all">
<method
name=".ctor" />
</type>
</assembly>
</linker>
Now App is building fine in Release mode as well.

Xamarin Android Background Location Service null

I used this demo to use background location services for my Android project (since Geolocator wouldn't background on Android). I haven't had any problems until yesterday when it gave me the following error:
[ServiceConnection] OnServiceConnected Called
Service Connected
[LocationService] You are about to get location updates via
[Mono] Assembly Ref addref Mono.Security[0xa7dd6ba0] -> System[0xadd5aac0]: 15
[Mono] DllImport attempting to load: '/system/lib/liblog.so'.
[Mono] DllImport loaded library '/system/lib/liblog.so'.
[Mono] DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
[Mono] Searching for '__android_log_print'.
[Mono] Probing '__android_log_print'.
[Mono] Found as '__android_log_print'.
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.IllegalArgumentException: invalid provider: null
[MonoDroid] at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ab9e0fea7db841c1a1450c120052eb14>:0
[MonoDroid] at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <ab9e0fea7db841c1a1450c120052eb14>:0
[MonoDroid] at Android.Locations.LocationManager.RequestLocationUpdates (System.String provider, System.Int64 minTime, System.Single minDistance, Android.Locations.ILocationListener listener) [0x0007e] in <21f1b0b5ad7242d7afaeceae3e6dbac8>:0
[MonoDroid] at Divco.LocationService.StartLocationUpdates () [0x0003c] in /Users/ediewoelfle/Developer/ancient-bastion-mobile/Droid/Services/LocationService.cs:78
[MonoDroid] at Divco.LocationServiceConnection.OnServiceConnected (Android.Content.ComponentName name, Android.OS.IBinder service) [0x0004f] in /Users/ediewoelfle/Developer/ancient-bastion-mobile/Droid/Services/LocationServiceConnection.cs:42
[MonoDroid] at Android.Content.IServiceConnectionInvoker.n_OnServiceConnected_Landroid_content_ComponentName_Landroid_os_IBinder_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_name, System.IntPtr native_service) [0x00019] in <21f1b0b5ad7242d7afaeceae3e6dbac8>:0
[MonoDroid] at (wrapper dynamic-method) System.Object.31(intptr,intptr,intptr,intptr)
[MonoDroid] --- End of managed Java.Lang.IllegalArgumentException stack trace ---
[MonoDroid] java.lang.IllegalArgumentException: invalid provider: null
[MonoDroid] at android.location.LocationManager.checkProvider(LocationManager.java:2317)
[MonoDroid] at android.location.LocationManager.requestLocationUpdates(LocationManager.java:490)
[MonoDroid] at md587a0a65fe57ffee4ef3988209babfc12.LocationServiceConnection.n_onServiceConnected(Native Method)
[MonoDroid] at md587a0a65fe57ffee4ef3988209babfc12.LocationServiceConnection.onServiceConnected(LocationServiceConnection.java:38)
[MonoDroid] at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1535)
[MonoDroid] at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1563)
[MonoDroid] at android.os.Handler.handleCallback(Handler.java:751)
[MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:95)
[MonoDroid] at android.os.Looper.loop(Looper.java:154)
[MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:6316)
[MonoDroid] at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
[MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="42" android:versionName="0.1" package="com.divcodelivery.divco">
<uses-sdk android:minSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application android:label="Divco" android:icon="#drawable/logo_size_icon">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.divcodelivery.divco.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data>
</provider>
</application>
</manifest>
I have located the null locationProvider, however, I am unsure WHY.

Exception when destroying MvxListView with footer

When adding a footer to the MvxListView, an exception is thrown when navigating away from the activity/fragment when the view is destroyed:
05-30 11:22:12.164 I/MonoDroid(27621): UNHANDLED EXCEPTION:
05-30 11:22:12.171 I/MonoDroid(27621): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Platforms.Android.Binding.Views.MvxListView.set_ItemsSource (System.Collections.IEnumerable value) [0x00006] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
05-30 11:22:12.171 I/MonoDroid(27621): at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
05-30 11:22:12.171 I/MonoDroid(27621): --- End of inner exception stack trace ---
05-30 11:22:12.171 I/MonoDroid(27621): at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004b] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
05-30 11:22:12.171 I/MonoDroid(27621): at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValueImpl (System.Object target, System.Object value) [0x0000c] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.Target.MvxConvertingTargetBinding.SetValue (System.Object value) [0x00090] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.Dispose (System.Boolean isDisposing) [0x00013] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.Target.MvxWithEventPropertyInfoTargetBinding.Dispose (System.Boolean isDisposing) [0x0001d] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.MvxBinding.Dispose () [0x00000] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.MvxFullBinding.ClearTargetBinding () [0x00039] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.MvxFullBinding.Dispose (System.Boolean isDisposing) [0x00003] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.Bindings.MvxBinding.Dispose () [0x00000] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.BindingContext.MvxBindingContext.ClearAllViewBindings () [0x00032] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Binding.BindingContext.MvxBindingContext.ClearAllBindings () [0x00000] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Droid.Support.V4.EventSource.MvxBindingFragmentAdapter.HandleDestroyViewCalled (System.Object sender, System.EventArgs e) [0x0000f] in <dffbd2c347de4e08a5c9f76935e21411>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Base.MvxDelegateExtensions.Raise (System.EventHandler eventHandler, System.Object sender) [0x00003] in <dcc1f804568a45a5accd2fb0ee5e5ebf>:0
05-30 11:22:12.171 I/MonoDroid(27621): at MvvmCross.Droid.Support.V4.EventSource.MvxEventSourceFragment.OnDestroyView () [0x00000] in <dffbd2c347de4e08a5c9f76935e21411>:0
05-30 11:22:12.171 I/MonoDroid(27621): at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <3682f8af23a748128467fbf9c57ae876>:0
05-30 11:22:12.171 I/MonoDroid(27621): at (wrapper dynamic-method) System.Object.7b7dc7e9-7935-455b-98b9-fc1831f50a54(intptr,intptr)
The list view is created using the following XAML:
<Mvx.MvxListView
android:id="#+id/voucher_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:MvxItemTemplate="#layout/voucher_list_item"
app:MvxBind="ItemsSource Vouchers" />
And the footer is added using:
var listView = view.FindViewById<MvxListView>(Resource.Id.voucher_list_view);
var footerView = this.BindingInflate(Resource.Layout.voucher_list_footer, null);
listView.AddFooterView(footerView, null, false);
This is the footers XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/voucher_list_footer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:MvxBind="Visibility Visibility(IsLoading)" />
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hent flere bilag"
style="#style/Widget.AppCompat.Button.Borderless"
app:MvxBind="Visibility Visibility(CanLoadMore); Click LoadVouchersCommand" />
</LinearLayout>
When removing the footer, the view is destroyed correctly. Any idea what is causing this issue?

Why does setting a style for StackLayout result in a NullReferenceException?

I want each Entry type in my in my StackLayout to have a margin. I'm trying to specify a style as follows:
<StackLayout IsVisible="{Binding IsLoggingIn, Converter={StaticResource BooleanConverter}}">
<StackLayout.Resources>
<Style TargetType="{x:Type Entry}">
<Setter Property="Margin" Value="0,0,0,20"/>
</Style>
</StackLayout.Resources>
<Entry ... />
<Entry ... />
</StackLayout>
Unfortunately, it results in a NullReferenceException:
04-13 16:26:15.406 E/mono (17167): Unhandled Exception:
04-13 16:26:15.406 E/mono (17167): System.NullReferenceException: Object reference not set to an instance of an object.
04-13 16:26:15.406 E/mono-rt (17167): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
With a bit more stack trace for reference:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at MyApp.Views.Login.InitializeComponent () [0x00012] in C:\dev\PathTo\MyApp\obj\Debug\MyApp.Views.Login.xaml.g.cs:22
at MyApp.Views.Login..ctor () [0x00008] in C:\dev\PathTo\MyApp\Views\Login.xaml.cs:9
at MyApp.App.SetupLoginPage () [0x00001] in C:\dev\PathTo\MyApp\App.xaml.cs:94
at MyApp.App+<OnStart>d__4.MoveNext () [0x001ad] in C:\dev\PathTo\MyApp\App.xaml.cs:60
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:35
at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81
at (wrapper dynamic-method) System.Object:d83972de-0492-4d07-a14d-24725ac1bfd1 (intptr,intptr)
What could be causing this, and how can I fix it? For the record, if I specify the margin inline e.g. <Entry margin="0,0,0,20"/>, it works fine.
I think your syntax is wrong. Shouldn't it be this;
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Entry">
<Setter Property="Margin" Value="0,0,0,20"/>
</Style>
</ResourceDictionary>
</StackLayout.Resources>
Note how I changed the TargetType and added the ResourceDictionary tag around it.

Xamarin Android popupwindow - crashes when inflated

I'm trying to create a pop up window that shows a clock (actually what i want is a countdown timer but one thing at a time!), the trouble is when i call the method to show the pop up window containing the clock, the app crashes.
The method is being called from an Activity not a fragment.
Here is the code:
public void clockPopup()
{
LayoutInflater inflater =(LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
View myPopup = inflater.Inflate (Resource.Layout.PopUpClockTimer, null);
RunOnUiThread (() => {
PopupWindow popup = new PopupWindow (myPopup);
});
}
The stack trace is as follows:
[mono] Unhandled Exception:
[mono] Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
[mono] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
[mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in <filename unknown>:0
[mono] at Android.Views.LayoutInflater.Inflate (Int32 resource, Android.Views.ViewGroup root) [0x00000] in <filename unknown>:0
[mono] at FrogPoint.Droid.MainActivity.clockPopup () [0x00020] in /Users/jakememery/Desktop/working Frogpoint/FrogPoint1.2_database/FindTheMonkey.Droid/MainActivity.cs:1548
[mono] at FrogPoint.Droid.MainActivity+<getBeaconData>c__async3.MoveNext () [0x00258] in /Users/jakememery/Desktop/working Frogpoint/FrogPoint1.2_database/FindTheMonkey.Droid/MainActivity.cs:1215
[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 System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
[mono] at FrogPoint.Droid.MainActivity+<RangingBeaconsInRegion>c__async0.MoveNext () [0x0035d] in /Users/jakememery/Desktop/working Frogpoint/FrogPoint1.2_database/FindTheMonkey.Droid/MainActivity.cs:675
[mono] --- End of managed exception stack trace ---
[mono] android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.AnalogClock
[mono] at android.view.LayoutInflater.createView(LayoutInflater.java:620)
[mono] at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
[mono] at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
[mono] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
[mono] at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
[mono] at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
[mono] at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
[mono] at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
[mono] at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
[mono] at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
[mono] at dalvik.system.NativeStart.run(Native Method)
[mono] Caused by: java.lang.reflect.InvocationTargetException
[mono] at java.lang.reflect.Constructor.constructNative(Native Method)
[mono] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[mono] at android.view.LayoutInflater.createView(LayoutInflater.java:594)
[mono] ... 10 more
[mono] Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
[mono] at android.os.Handler.<init>(Handler.java:200)
[mono] at android.os.Handler.<init>(Handler.java:114)
[mono] at android.widget.AnalogClock.<init>(AnalogClock.java:57)
[mono] at android.widget.AnalogClock.<init>(AnalogClock.java:67)
Here is the XML i'm trying to inflate:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/customborder"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical">
<TextView
android:id="#+id/textout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Time sensitive offer" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/logo76" />
<AnalogClock
android:id="#+id/tabAnalogClock"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<DigitalClock
android:id="#+id/tabDigitalClock"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="#+id/dismiss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dismiss" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Can anybody see where i'm going wrong here please?
It seems i simply needed to call the method like this:
RunOnUiThread (() => {
clockPopup();
});
It doesn't crash now. But unfortunately neither does it display the pop up. But that's for another post.
You are missing either:
popup.ShowAtLocation(...);
or
popup.ShowAsDropDown(...);
to actually display the popup window.

Resources