title: Xamarin Android | Could not activate JNI Handle
body: <p>Android, Could somebody tell me why do I get this error:</p>
  
  <pre><code>System.NotSupportedException: Could not activate JNI Handle 0x5400029 (key_handle 0x4272e7c8) of Java type 'md53e540c9aae5d831a93a27cad628f9744/Timer' as managed type 'Timer.Timer'.
  </code></pre>
  
  <p>I get it when i try to assign some method to any button in my class Timer</p>
  
  <p>Example</p>
  
  <pre><code>secondsBtn.Click+=delegate{
  
  };
  </code></pre>
  
  <p>When I add this to the constructor it throws the mistake</p>
  
  <p>This is my class</p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using Android.App;
      using Android.Content;
      using Android.Graphics;
      using Android.OS;
      using Android.Runtime;
      using Android.Views;
      using Android.Widget;
      using Android.Util;
      using Android.Support.V4.Content;
      using System.Threading;
  
      namespace Timer
      {
  
  
          class Timer : View
          {
              private Paint paint1 = new Paint();
              private Paint paint2 = new Paint();
              private Paint paint3 = new Paint();
  
              private int offset = 5;
              private int timerWidth = 15;
  
              private Color LightGray { get; set; }
              private Color DarkGray { get; set; }
              private Color AzureBlue { get; set; }
              private Color BGcolor { get; set; }
  
              private int Seconds { get; set; }
              private int Minutes { get; set; }
              private int Gours { get; set; }
              System.Timers.Timer t = new System.Timers.Timer(1000);
              private int DegreesFroSeconds = 360 / 60;
  
              private TextView secondsTxtView;
              private TextView minutesTxtView;
              private TextView hoursTxtView;
  
  
              private Button secondsBtn;
              private Button minutesBtn;
              private Button hoursBtn;
  
              private TextView insideTxtTimeView;
              private TextView insideTxtTypeView;
  
  
  
              public Timer(Context context) : base(context)
              {
              }
  
              public Timer(Context context, IAttributeSet attrs) : base(context, attrs)
              {
                  Invalidate();
                  LightGray = GetColorFromInteger(ContextCompat.GetColor(context, Resource.Color.light_gray));
                  DarkGray = GetColorFromInteger(ContextCompat.GetColor(context, Resource.Color.dark_gray));
                  AzureBlue = GetColorFromInteger(ContextCompat.GetColor(context, Resource.Color.azure_blue));
                  BGcolor = GetColorFromInteger(ContextCompat.GetColor(context, Resource.Color.bg_color));
  
  
                  secondsTxtView = FindViewById&lt;TextView&gt;(Resource.Id.timer_txt_view_seconds);
                  minutesTxtView = FindViewById&lt;TextView&gt;(Resource.Id.timer_txt_view_minutes);
                  hoursTxtView = FindViewById&lt;TextView&gt;(Resource.Id.timer_txt_view_hours);
  
                  secondsBtn = FindViewById&lt;Button&gt;(Resource.Id.timer_bt_seconds);
                  minutesBtn = FindViewById&lt;Button&gt;(Resource.Id.timer_bt_minutes);
                  hoursBtn = FindViewById&lt;Button&gt;(Resource.Id.timer_bt_hours);
  
                  insideTxtTimeView = FindViewById&lt;TextView&gt;(Resource.Id.timer_inside_time_view);
                  insideTxtTypeView = FindViewById&lt;TextView&gt;(Resource.Id.timer_inside_type_view);
  
  
  
  
                  paint1.Color = DarkGray;
                  paint1.TextSize = 230;
  
                  paint2.Color = BGcolor;
                  paint3.Color = AzureBlue;
  
  
                  t.Elapsed += delegate
                  {
                      Seconds++;
                      Seconds = Seconds % 60;
                      ((Activity)Context).RunOnUiThread(delegate { Invalidate(); });
                  };
                  t.Start();
  
  
              }
  
  
              private void ClearTxtViews()
              {
                  secondsTxtView.SetTextColor(DarkGray);
                  minutesTxtView.SetTextColor(DarkGray);
                  hoursTxtView.SetTextColor(DarkGray);
  
                  secondsBtn.SetTextColor(DarkGray);
                  minutesBtn.SetTextColor(DarkGray);
                  hoursBtn.SetTextColor(DarkGray);
              }
  
              protected override void OnDraw(Canvas canvas)
              {
  
                  Point middle = new Point(Width / 2, Height / 2);
                  int radius = Height / 2 - offset;
                  base.OnDraw(canvas);
                  canvas.DrawCircle(Width / 2, Height / 2, Height / 2 - offset, paint1);
                  canvas.DrawArc(new RectF(middle.X - radius, middle.Y - radius, middle.X + radius, middle.Y + radius), -90, DegreesFroSeconds * Seconds, true, paint3);
                  canvas.DrawCircle(Width / 2, Height / 2, Height / 2 - (offset + timerWidth), paint2);
              }
              public static Color GetColorFromInteger(int color)
              {
                  return Color.Rgb(Color.GetRedComponent(color), Color.GetGreenComponent(color), Color.GetBlueComponent(color));
              }
          }
      }
  </code></pre>