I have an installed WCF service on my computer. And I can successfully connect to this service from Console app on windows, but if i use the same code on android it doesn't work.
using System;
using System.ServiceModel;
using Android.App;
using Android.Widget;
using Android.OS;
namespace App1
{
[ServiceContract]
public interface ILogonService
{
[OperationContract]
string Logon(string appId);
}
[Activity(Label = "App1", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += ButtonOnClick;
}
private void ButtonOnClick(object sender, EventArgs eventArgs)
{
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var endPointUri = new Uri(#"http://192.168.1.241/edo/Euphrates.svc/ILogonService-Basic");
var factory = new ChannelFactory<ILogonService>(binding, new EndpointAddress(endPointUri));
factory.Credentials.UserName.UserName = "test";
factory.Credentials.UserName.Password = "test";
ILogonService service = factory.CreateChannel();
Console.WriteLine(service.Logon("test"));
}
}
}
I am getting this error:
"System.Net.WebException: There was an error on processing web
request: Status code 401(Unauthorized): Unauthorized". 11-19
18:16:29.973 E/mono ( 1177): 11-19 18:16:29.973 E/mono ( 1177):
Unhandled Exception: 11-19 18:16:29.973 E/mono ( 1177):
System.Net.WebException: There was an error on processing web request:
Status code 401(Unauthorized): Unauthorized 11-19 18:16:29.973 E/mono
( 1177): at
System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.WaitEnd
() [0x00000] in :0 11-19 18:16:29.973 E/mono ( 1177): at
System.ServiceModel.Channels.HttpRequestChannel.EndRequest
(IAsyncResult result) [0x00000] in :0 11-19 18:16:29.973 E/mono (
1177): at System.ServiceModel.Channels.HttpRequestChannel.Request
(System.ServiceModel.Channels.Message message, TimeSpan timeout)
[0x00000] in :0 11-19 18:16:29.973 E/mono ( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000]
in :0 11-19 18:16:29.973 E/mono ( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od,
System.Object[] parameters) [0x00000] in :0 11-19 18:16:29.973 E/mono
( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in :0 11-19 18:16:29.973 E/mono
( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in :0
How can I solve this problem? Any ideas?
Thanks
Related
[Xamarin.Forms.GoogleMaps][1] is failing when deploying to IOS (in my case iPhone phisical device).
The app is trying to start but then crashes to the OS. Visual Studio does not catch the break point.
In the output window I get this:
Loaded assembly:
/private/var/mobile/Containers/Data/Application/BE8F87C7-8FB5-4F76-9674-03D160780B77/Documents/XFGoogleMapSampleiOS.content/Xamarin.Forms.Xaml.dll
[External] Loaded assembly:
/private/var/containers/Bundle/Application/F4979BA1-4F02-476D-BB93-7A84EE654A10/XFGoogleMapSampleiOS.app/System.Xml.dll
[External] Thread started: #4 Thread started: #5 Thread started: #6 Thread started: #7 Resolved pending breakpoint at 'BasicMapPage.xaml.cs:139,1'
to void XFGoogleMapSample.BasicMapPage.<.ctor>b__0_15 (object sender,
Xamarin.Forms.GoogleMaps.CameraChangedEventArgs args) [0x00008].
Loaded assembly:
/private/var/containers/Bundle/Application/F4979BA1-4F02-476D-BB93-7A84EE654A10/XFGoogleMapSampleiOS.app/System.Net.Http.dll
[External] Loaded assembly:
/private/var/containers/Bundle/Application/F4979BA1-4F02-476D-BB93-7A84EE654A10/XFGoogleMapSampleiOS.app/System.Drawing.Common.dll
[External] [0:] An error occurred: 'Object reference not set to an
instance of an object.'. Callstack: ' at
Xamarin.Forms.GoogleMaps.iOS.MapRenderer.UpdateIsShowingUser
(System.Nullable1[T] initialMyLocationButtonEnabled) <0x119727660 + 0x0007a> in <cae073484d4d4db5b36708f421f24080>:0 at Xamarin.Forms.GoogleMaps.iOS.MapRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e)
<0x118649e28 + 0x002d0> in :0 at
Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00134] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:193 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement
(Xamarin.Forms.VisualElement element) [0x00000] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:141 at
Xamarin.Forms.Platform.iOS.Platform.CreateRenderer
(Xamarin.Forms.VisualElement element) [0x00014] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:199 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded
(Xamarin.Forms.VisualElement view) [0x0004f] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:79 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:46 at
Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000f0] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:180 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement
(Xamarin.Forms.VisualElement element) [0x00000] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:141 at
Xamarin.Forms.Platform.iOS.Platform.CreateRenderer
(Xamarin.Forms.VisualElement element) [0x00014] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:199 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded
(Xamarin.Forms.VisualElement view) [0x0004f] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:79 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:46 at
Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x00086] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:123
at (wrapper managed-to-native)
ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr) at
UIKit.UIViewController.get_View () [0x0002a] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/14.2.0.12/src/Xamarin.iOS/UIKit/UIViewController.g.cs:3267
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000]
in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:41
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement
(Xamarin.Forms.VisualElement element) [0x0004f] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:56 at
Xamarin.Forms.Platform.iOS.Platform.CreateRenderer
(Xamarin.Forms.VisualElement element) [0x00014] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:199 at
Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage
(Xamarin.Forms.Page page) [0x00008] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:357
at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync
(Xamarin.Forms.Page page, System.Boolean animated) [0x0001d] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:344
at Xamarin.Forms.Platform.iOS.NavigationRenderer.b__42_0
(Xamarin.Forms.Page p) [0x00024] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:228
at
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0
(System.Object state) [0x00000] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at (wrapper delegate-invoke) .invoke_void_object(object) at
Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000]
in
/Library/Frameworks/Xamarin.iOS.framework/Versions/14.2.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:178
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native)
UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at
UIKit.UIApplication.Main (System.String[] args, System.IntPtr
principal, System.IntPtr delegate) [0x00005] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/14.2.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x0000e] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/14.2.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at XFGoogleMapSample.iOS.Application.Main (System.String[] args)
[0x00001] in
C:\Projects\Xamarin.Forms.GoogleMaps-master\XFGoogleMapSample\iOS\Main.cs:17
at (wrapper managed-to-native)
System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj,
System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder
binder, System.Object[] parameters, System.Globalization.CultureInfo
culture) [0x0006a] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395
' The app has been terminated.
First, I tried on my local project. After, I decided to get the source code of the googlemaps libray from git hub and debug it.
It breaks in the MapRenderer.cs
private void UpdateIsShowingUser(bool? initialMyLocationButtonEnabled = null)
{
#pragma warning disable 618
((MapView)Control).MyLocationEnabled = ((Map)Element).IsShowingUser;
((MapView)Control).Settings.MyLocationButton = initialMyLocationButtonEnabled ?? ((Map)Element).IsShowingUser;
#pragma warning restore 618
}
Apparently the native Google.Maps.MapView.Settings is null here. I am not sure what exacly am I doing wrong, but the same library works perfect in Andoid version. It only fails in IOS.
I have set up API keys and API on google developer console.
Visual Studio Version 16.7.7
IOS 14.1
Xamarin.iOS 14.2.0.12
I also tried the standard xamarin google maps lirary and it works fine (it just miss many features comparing to Xamarin.Forms.GoogleMaps)
[1]: https://github.com/amay077/Xamarin.Forms.GoogleMaps
I'm using lib MySql.Data to try connect and insert some data in a table but
My Code:
using System;
using System.Data;
using MySql.Data.MySqlClient;
public class DBCon
{
public static class Banco
{
public static async void Executar(string query)
{
var connection = new MySqlConnection("Server=XXXXXXX;Database=YYYYYYYYY;Uid=ZZZZZZZ;Pwd=PPPPPPPPP");
var command = connection.CreateCommand();
try
{
connection.Open();
command.CommandText = query;
command.ExecuteNonQuery();
}
catch(Exception)
{
throw;
}
finally
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
}
}
}
Executing the query:
DBCon.Banco.Executar("INSERT INTO table (device,latitude,longitude) VALUES ('abc123','"+position.Latitude+"','"+position.Longitude+"')");
Getting these lines while debugging:
10-12 00:41:32.931 E/mono (12296):
10-12 00:41:32.931 E/mono (12296): Unhandled Exception:
10-12 00:41:32.931 E/mono (12296): System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
---> System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception.
---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationHost.GetStreamName (System.String configPath) [0x0006d] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp () [0x00006] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationSystem..ctor () [0x00051] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00024] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): --- End of inner exception stack trace --- 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00060] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.PrepareConfigSystem () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.931 E/mono (12296): --- End of inner exception stack trace --- 10-12 00:41:32.931 E/mono (12296): at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.931 E/mono (12296): --- End of inner exception stack trace --- 10-12 00:41:32.931 E/mono (12296): at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.931 E/mono (12296): at DBCon+Banco+<Executar>d__0.MoveNext () [0x00059] in D:\apps\BatePapo\BatePapo\BatePapo\DBCon.cs:22 10-12 00:41:32.931 E/mono (12296): --- End of stack trace from previous location where exception was thrown --- 10-12 00:41:32.931 E/mono (12296): at (wrapper dynamic-method) System.Object.47(intptr,intptr) 10-12 00:41:32.932 E/mono-rt (12296): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.PlatformNotSupportedException: Operation is not supported on this platform. 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationHost.GetStreamName (System.String configPath) [0x0006d] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp () [0x00006] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationSystem..ctor () [0x00051] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00024] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): --- End of inner exception stack trace --- 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00060] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.PrepareConfigSystem () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.932 E/mono-rt (12296): --- End of inner exception stack trace --- 10-12 00:41:32.932 E/mono-rt (12296): at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.932 E/mono-rt (12296): --- End of inner exception stack trace --- 10-12 00:41:32.932 E/mono-rt (12296): at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.932 E/mono-rt (12296): at DBCon+Banco+<Executar>d__0.MoveNext () [0x00059] in D:\apps\BatePapo\BatePapo\BatePapo\DBCon.cs:22 10-12 00:41:32.932 E/mono-rt (12296): --- End of stack trace from previous location where exception was thrown --- 10-12 00:41:32.932 E/mono-rt (12296): at (wrapper dynamic-method) System.Object.47(intptr,intptr) 10-12 00:41:32.935 D/ (12296): HostConnection::get() New Host Connection established 0xd02c5500, tid 12296
Can anyone see what is the error?
I'm getting the following error when trying to set an icon on a Google Maps Map Marker:
[ERR] 26/06/2018 10:02:25 a.m. : Failed to decode image. The provided
image must be a Bitmap. [ERR] 26/06/2018 10:02:25 a.m. : at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in <0711a0626e0e4d58a44e8ca32787a4a9>:0 at
Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod
(Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo
method, Java.Interop.JniArgumentValue* args) [0x00069] in
:0 at
Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject,
System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in
<5680b8d3acca4700bde9a113c467e3e5>:0 at
Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject,
System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in
<5680b8d3acca4700bde9a113c467e3e5>:0 at
Android.Gms.Maps.Model.Marker.SetIcon
(Android.Gms.Maps.Model.BitmapDescriptor icon) [0x0004b] in
<51f505f20f3f4c27854ba8f47994abdb>:0 at
AMCS.Mobile.Mapping.Android.MarkerManager.UpdateMarker
(AMCS.Mobile.Entity.Mapping.IMarker markerInfo) [0x00083] in
:0 at
AMCS.Mobile.Mapping.Android.MapHelper.UpdateMarker
(AMCS.Mobile.Entity.Mapping.IMarker markerInfo) [0x00000] in
:0 at
AMCS.Mobile.AMCSMobile.Client.Android.CollectionRouteView.b__462_0
() [0x00000] in <1d292c66dbaa42139a432bad3cbbbc7b>:0 at
Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in
<5680b8d3acca4700bde9a113c467e3e5>:0 at
Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr
native__this) [0x00008] in <5680b8d3acca4700bde9a113c467e3e5>:0 at
(wrapper dynamic-method)
System.Object:6aee8cf7-156f-44a9-94d5-15cb0790d815 (intptr,intptr)
--- End of managed Java.Lang.RuntimeException stack trace --- com.google.maps.api.android.lib6.common.apiexception.b: Failed to
decode image. The provided image must be a Bitmap. at
com.google.maps.api.android.lib6.impl.n.a(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):12) at
com.google.maps.api.android.lib6.impl.o.a(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):7) at
com.google.maps.api.android.lib6.impl.cy.a(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):186) at
com.google.android.gms.maps.model.internal.q.onTransact(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):87) at android.os.Binder.transact(Binder.java:507)
at com.google.android.gms.maps.model.internal.l$a$a.n(Unknown Source)
at com.google.android.gms.maps.model.Marker.setIcon(Unknown Source)
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:751) at
android.os.Handler.dispatchMessage(Handler.java:95) at
android.os.Looper.loop(Looper.java:154) at
android.app.ActivityThread.main(ActivityThread.java:6780) at
java.lang.reflect.Method.invoke(Native Method) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
I can see that it's failing in the UpdateMarker method which looks like the following:
public void UpdateMarker(IMarker markerInfo)
{
// _markerLookup is a dictionary defined earlier as:
// private Dictionary<IMarker,Android.Gms.Maps.Model.Marker> _markerLookup = new Dictionary<IMarker, Android.Gms.Maps.Model.Marker>();
// It is populated elsewhere
// Check if the dictionary contains a key for the given value
if (_markerLookup.ContainsKey(markerInfo))
{
Android.Gms.Maps.Model.Marker marker = _markerLookup[markerInfo];
marker.Position = new LatLng(markerInfo.MapCoordinate.Lat, markerInfo.MapCoordinate.Lng);
marker.Draggable = markerInfo.MarkerOptions.IsDraggable;
// Create BitmapDescriptor from Resource - Blue_Vehicle definitely exists and is a .png image
BitmapDescriptor bitmapDesc =
BitmapDescriptorFactory.FromResource(Resource.Drawable.Blue_Vehicle);
if (bitmapDesc != null)
{
marker.SetIcon(bitmapDesc);
}
}
}
The marker.SetIcon method is looking for a BitMapDescriptor which as described above is created from an image resource.
I don't understand why it's throwing an exception.
I would greatly appreciate if someone could shed some light on the issue.
I am trying to create a mobile application using MvvmCross v.4.4.0.
Application works correct. But if collapse application and lock the phone, and then unlock and press "Overview" android button application crash (only on the Xiaomi phone).
I think android kills activity and then unsuccessfully trying to recreate it.
Could you, please explain me, what I do wrong? How to fix it?
Stacktrace:
Android.Runtime.RaiseThrowableEventArgs MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type Test.Core.ViewModels.MainMenuViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information ---> MvvmCross.Platform.Exceptions.MvxException: Problem creating viewModel of type MainMenuViewModel ---> MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to construct MainMenuViewModel ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Java.Lang.LinkageError: no static method "Landroid/text/Html;.fromHtml(Ljava/lang/String;I)Landroid/text/Spanned;" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in <89dd20b27a0b473a848558c84f1f086a>:0 at Java.Interop.JniEnvironment+StaticMethods.GetStaticMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature)
[0x00068] in :0 at Java.Interop.JniType.GetStaticMethod (System.String name, System.String signature)
[0x0000d] in :0 at Java.Interop.JniPeerMembers+JniStaticMethods.GetMethodInfo (System.String encodedMember)
[0x0003c] in :0 at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters)
[0x00001] in :0 at Android.Text.Html.FromHtml (System.String source, Android.Text.FromHtmlOptions flags)
[0x0003b] in :0 at Test.Droid.Providers.DialogProvider.ShowSnackbar () [0x00017] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Test.Core.ViewModels.BaseViewModel..ctor ()
[0x0006d] in :0 at Test.Core.ViewModels.MainMenuViewModel..ctor (Test.Core.Managers.IExceptionManager exceptionManager)
[0x0000b] in :0 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters)
[0x00002] in <89dd20b27a0b473a848558c84f1f086a>:0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters)
[0x0001c] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00089] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00000] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters)
[0x00000] in <89dd20b27a0b473a848558c84f1f086a>:0 at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type)
[0x0003a] in <4ddde23419c5494288c799fcdbb0f189>:0 --- End of inner exception stack trace --- at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type)
[0x0005b] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Platform.Mvx.IocConstruct (System.Type t)
[0x00005] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00000] in <69bce0378e8e413982d3b552d7e387a8>:0 --- End of inner exception stack trace --- at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00027] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator)
[0x00015] in <69bce0378e8e413982d3b552d7e387a8>:0 --- End of inner exception stack trace --- at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator)
[0x00046] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00020] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.ViewModelFromRequest (MvvmCross.Core.ViewModels.MvxViewModelRequest viewModelRequest, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00005] in :0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.CreateViewModelFromIntent (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00027] in :0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.Load (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState, System.Type viewModelTypeHint)
[0x00089] in :0 at MvvmCross.Droid.Views.MvxActivityViewExtensions.LoadViewModel (MvvmCross.Droid.Views.IMvxAndroidView androidView, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x0006a] in :0 at MvvmCross.Droid.Views.MvxActivityViewExtensions+<>c__DisplayClass1_0.b__1 ()
[0x0000a] in :0 at MvvmCross.Core.Views.MvxViewExtensionMethods.OnViewCreate (MvvmCross.Core.Views.IMvxView view, System.Func`1[TResult] viewModelLoader)
[0x00012] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (MvvmCross.Droid.Views.IMvxAndroidView androidView, Android.OS.Bundle bundle)
[0x00062] in :0 at MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs`1[T] eventArgs)
[0x0000c] in :0 at (wrapper delegate-invoke) System.EventHandler`1[MvvmCross.Platform.Core.MvxValueEventArgs`1[Android.OS.Bundle]]:invoke_void_object_TEventArgs (object,MvvmCross.Platform.Core.MvxValueEventArgs`1) at MvvmCross.Platform.Core.MvxDelegateExtensionMethods.Raise[T] (System.EventHandler`1[TEventArgs] eventHandler, System.Object sender, T value)
[0x0000b] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Platform.Droid.Views.MvxEventSourceActivity.OnCreate (Android.OS.Bundle bundle)
[0x00014] in <4230cf00b647458f9b3e211590e6cc9d>:0 at Test.Droid.Views.BaseView`1[TViewModel].OnCreate (Android.OS.Bundle bundle)
[0x00000] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Test.Droid.Views.MainMenuView.OnCreate (Android.OS.Bundle bundle)
[0x00000] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState)
[0x00011] in :0 at (wrapper dynamic-method) System.Object:e6d6ef29-3746-4c8e-b037-c64f6dfe49f0 (intptr,intptr,intptr)
This is a linking issue. You have some kind of DialogProvider, which uses the Android.Text.Html.FromHtml method, which seems to be stripped out.
You can add expressions to LinkerPleaseInclude.cs to prevent the linker from removing code or you can add [Preserve(AllMembers = true)] attribute on your DialogProvider class.
On Android I am getting this error Java.Lang.IllegalArgumentException:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (object) [0x00000] in /Users/builder/data/lanes/2058/58099c53/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
at Android.App.SyncContext/c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.IRunnable.cs:71
at (wrapper dynamic-method) object.7dac782f-30e4-45cb-a248-e0c4c79fbcad (intptr,intptr)
--- End of managed exception stack trace --- java.lang.IllegalArgumentException at
android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:169) at dalvik.system.NativeStart.run(Native Method)
using this code to retrive *.mp3 file duration:
public async Task<string> GetTrackDuration(string pathToFile)
{
MediaMetadataRetriever reader = new MediaMetadataRetriever();
await reader.SetDataSourceAsync (global::Android.App.Application.Context, Android.Net.Uri.Parse (pathToFile));
return reader.ExtractMetadata(MetadataKey.Duration).ToString();
}
where is the problem? I have tried all of the posible constructors