I have my java source code exported into a .jar file in eclipse. I have created a java binding library in Xamarin and added the .jar file into the jars folder. I have further referenced the library project into my Xamarin android project.
This is the code for my activity:-
public class HorizontalActivity : Activity
{
private FVControl fView;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
Title = Resource.String.activity_title.ToString ();
fView = new FViewControl(this, FVControl.Horizontal);
fView.Adapter = (Android.Widget.IAdapter)new TravelAdapter (this);
SetContentView (fView);
}
I get the error:-
[MonoDroid] UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
[MonoDroid] at FJarLibraryTest.HorizontalActivity.OnCreate (Android.OS.Bundle) <0x0010f>
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00048>
[MonoDroid] at (wrapper dynamic-method) object.be54cf5e-5a7f-424b-a1e2-a76991021bdd (intptr,intptr,intptr) <0x0001f>
[mono]
[mono] Unhandled Exception:
[mono] System.InvalidCastException: Cannot cast from source type to destination type.
[mono] at FJarLibraryTest.HorizontalActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
[mono] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
[mono] at (wrapper dynamic-method) object:be54cf5e-5a7f-424b-a1e2-a76991021bdd (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
[mono-rt] at FJarLibraryTest.HorizontalActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
[mono-rt] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
[mono-rt] at (wrapper dynamic-method) object:be54cf5e-5a7f-424b-a1e2-a76991021bdd (intptr,intptr,intptr)