Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

System.ArgumentException: Handle must be valid. Parameter name: type #152

Open
lassana opened this issue Apr 1, 2019 · 4 comments
Open

Comments

@lassana
Copy link

lassana commented Apr 1, 2019

Bug Information

Version Number of Plugin: 3.1.1
Device Tested On: Sony Xperia XZ1 with Android 9.
Simulator Tested On: -
Version of VS: -
Version of Xamarin: app was built with MonoAndroid 8.1
Versions of other things you are using: -

Steps to reproduce the Behavior

It's random. Personally I wasn't able to reproduce it but I received a few crash reports. Looking at the stacktrace I believe it may relate to xamarin/Essentials#380

Expected Behavior

App doesn't crash.

Actual Behavior

App crashes:

Java.Interop.JniEnvironment+InstanceMethods.GetMethodID(Java.Interop.JniObjectReference type, System.String name, System.String signature) in <5e2db96f839b4c6aa872f8242b2dbdfc>:0
Android.Runtime.JNIEnv.GetMethodID(System.IntPtr kls, System.String name, System.String signature) in <c9894edee12e4450bfacd1a83cdaa6fb>:0
Android.Content.ISharedPreferencesInvoker.Contains(System.String key) in <c9894edee12e4450bfacd1a83cdaa6fb>:0
Plugin.Settings.SettingsImplementation.Contains(System.String key, System.String fileName) in <4cb80ca5509444fa8d9fd4d0a436e069>:0
Plugin.Settings.SettingsImplementation.GetValueOrDefaultInternal[T](System.String key, T defaultValue, System.String fileName) in <4cb80ca5509444fa8d9fd4d0a436e069>:0
Plugin.Settings.SettingsImplementation.GetValueOrDefault(System.String key, System.String defaultValue, System.String fileName) in <4cb80ca5509444fa8d9fd4d0a436e069>:0
MyApp.Utils.Preferences.get_IsLoginInfoSaved() in <67a6630ac5984211b8d4ac1871f56342>:0
MyApp.Utils.AzureSyncTimer.Do() in <67a6630ac5984211b8d4ac1871f56342>:0
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0(System.Object state) in <e41ba7246f28401eb5844b0796036a8e>:0
Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0() in <c9894edee12e4450bfacd1a83cdaa6fb>:0
Java.Lang.Thread+RunnableImplementor.Run() in <c9894edee12e4450bfacd1a83cdaa6fb>:0
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in <c9894edee12e4450bfacd1a83cdaa6fb>:0

Code snippet

Preferences.get_IsLoginInfoSaved has the following code:

_settingsInstance.GetValueOrDefault(KeyUsername, null)

_settingsInstance is an ISettings instance.

@dechosenuchenna
Copy link

I just magically started getting this error recently. i have two apps listening to the same firebase reference. when i call the setvalue() method i get this exception.

@sillerjp
Copy link

sillerjp commented May 2, 2019

Having this issue too. Mine happens when I try to access Xamarin.Essentials.Preferences through "ViewAppeared" lifecycle method in MvvmCross Viewmodel.

Specifically when coming back from another activity.

@HadiHas
Copy link

HadiHas commented Jan 8, 2020

Im getting this issue randomly as well on
var UserType = Plugin.SecureStorage.CrossSecureStorage.Current.GetValue("UserType");

with crosssecurestorage

we are using Xamarin.Android
were you able to solve this issue?

@guillermo-gerard
Copy link

I found this issue and even though I'm not using Essentials, I want to share how I stopped this from occurring:
I was using just sharedPreferences as I'm working on a xamarin android app, and I was trying to write a value from inside a catch block.
I just took off that from the catch block and I stopped receiving this exception.
I hope this may be useful for someone else...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants