NotSupportedException Could not activate JNI Handle - MvvmCross
Asked Answered
I

1

7

I recently updated MvvmCross from 3.5.1 to 4.1.4 in my project and published the app update along with it.

After that, I see from Xamarin Insights that, a lot of users experience;

Could not activate JNI Handle 0xffb35af8 (key_handle 0xe888654) of Java type 'md53997af0c1a24144057e197743f9f827a/HomeView' as managed type 'package.name.HomeView' on almost all of the activities with their respective activity names. All these activities are MvxActivities.

My Setup.cs -

public class Setup : MvxAndroidSetup
{
    public Setup(Context applicationContext)
        : base(applicationContext)
    {
    }

    protected override IMvxApplication CreateApp()
    {
        return new MVVM.App();
    }

    protected override IMvxTrace CreateDebugTrace()
    {
        return new MvxDebugTrace();
    }

    protected override MvvmCross.Droid.Views.IMvxAndroidViewPresenter CreateViewPresenter()
    {
        var presenter = new MyViewPresenter();

        Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);

        return presenter;
    }

    protected override void FillTargetFactories(MvvmCross.Binding.Bindings.Target.Construction.IMvxTargetBindingFactoryRegistry registry)
    {
        registry.RegisterCustomBindingFactory<View>(
                 "ShowMe",
                 v => new ViewScalingCustomBinding(v));
        registry.RegisterCustomBindingFactory<View>(
                 "ScaleMe",
                 v => new ViewSizingCustomBinding(v));
        registry.RegisterCustomBindingFactory<View>(
                 "CustomFont",
                 v => new FontCustomBinding(v));
        registry.RegisterCustomBindingFactory<View>(
                 "OtherCustomFont",
                 v => new FontDincCustomBinding(v));
        registry.RegisterCustomBindingFactory<View>(
                 "ImageResize",
                 v => new ImageResizeCustomBinding(v));
        base.FillTargetFactories(registry);
    }

    protected override IMvxPluginConfiguration GetPluginConfiguration(Type plugin)
    {
        if (plugin == typeof(MvvmCross.Plugins.DownloadCache.Droid.Plugin))
        {
            return new MvvmCross.Plugins.DownloadCache.Droid.MvxDownloadCacheConfiguration()
            {
                CacheName = "Pictures.MvvmCross",
                CacheFolderPath = "../Library/Caches/Pictures.MvvmCross/",
                MaxFiles = 500,
                MaxFileAge = TimeSpan.FromDays(1),
                MaxInMemoryBytes = 4000000, // 4 MB
                MaxInMemoryFiles = 1,
                MaxConcurrentDownloads = 10,
                DisposeOnRemoveFromCache = false
            };
        }

        return null;
    }
}

What could be causing this issue?

Individuate answered 31/5, 2016 at 8:49 Comment(7)
Can you maybe show one of those Activites? And maybe your Setup.cs? Quite a few things have changed with 4, so maybe there is something wrong with the activity headers or so.Marocain
Aside from namespaces and namespace related things, I haven't changed anything in Setup.cs, but I can add it to the question. Activity headers also don't have anything specific except a label and screen orientation.Individuate
And it appears only with some users, you yourself dont have this issue?Marocain
Exactly, I see a lot of users experience it, but I don't, during debugging, and neither our QA team.Individuate
Maybe related to the android version? Do you have any information about that from the affected devices? Not sure if things like MvxAppCompatActivity instead of MvxActivity would make a difference.Marocain
I have the android version info, but it is varied so I don't think it affects a specific version. It seems to be affecting all versions.Individuate
Let us continue this discussion in chat.Marocain
R
3

I had that exception without using any custom view. Just try to clean the project, it solved my issue, however still that kind of thing scares me from using Xamarin.

Randyranee answered 15/5, 2017 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.