Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Could not activate JNI Handle

mohammadomidvarmohammadomidvar USMember ✭✭
edited July 2017 in Xamarin.Android

I want to customize viewpager to make it work vertically. But when setting contentview app cannot create an instance of it and give this error:

System.NotSupportedException: Could not activate JNI Handle 0xeab00029 (key_handle 0x41357db0) of Java type 'md5b3f8461ca967df4f0978d2e01bf012d6/VViewPager' as managed type 'App3.Widgets.VViewPager'.

The custom viewpager:

namespace App3.Widgets
    public class VViewPager : ViewPager
        public VViewPager(Context c) : base(c) { Initialize(); }
        public VViewPager(Context c, Android.Util.IAttributeSet attrs) : base(c, attrs) { Initialize(); }
        public VViewPager(IntPtr jr, JniHandleOwnership transfer) : base(jr, transfer) { Initialize(); }

        private void Initialize()
            SetPageTransformer(true, new VerticalPageTransformer());

            OverScrollMode = OverScrollMode.Never;

        private MotionEvent SwapXandY(MotionEvent ev)
            ev.SetLocation(ev.GetY() / Height * Width, ev.GetX() / Width * Height);
            return ev;

        public override bool OnInterceptTouchEvent(MotionEvent ev) => base.OnInterceptTouchEvent(SwapXandY(ev));

        public override bool OnTouchEvent(MotionEvent ev) => base.OnTouchEvent(SwapXandY(ev));

        private class VerticalPageTransformer : IPageTransformer
            //some codes for changing behavior


Best Answer


  • mohammadomidvarmohammadomidvar USMember ✭✭
    Accepted Answer

    Answer is provided here :
    Any method that modifies View before it is created can cause this, in my case: Initialize()

  • nivekkocnivekkoc IEMember

    Hi, Im having the same issue,
    What did you have to do to rectify this?
    Where did you call initialise?

  • mohammadomidvarmohammadomidvar USMember ✭✭

    I made Initialize() public and I call it in my activity or anywhere that view is found or created.

  • nivekkocnivekkoc IEMember

    Thanks you are a gent!!
    Just one other thing did you manage to get the verticalviewpager
    to slide when swipe up and down rather than left and right?

  • nivekkocnivekkoc IEMember

    Actually i found it, thanks
    I never added SwapXandY(ev)

  • MahdibabaMahdibaba Member
    edited April 15

    1.Install-Package SQLite-Net-PCL properties of project go to android manifest tab and give read-external-storage and write-external-storage. constructor of connection class write this code.

        private string dbpath = "";
        private string dbName = "YourDB";
        SQLiteConnection db;
        public FriendManagMent()
            dbpath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

    db=new SQLiteConnection(Path.Combine(dbpath,dbName));

Sign In or Register to comment.