I was able to get the error to go away by deleting the backup of my phone, and putting an exception into AndroidManifest to not backup the Maui SecureSettings keys. Hopefully that will fix it.
Suddenly getting SecureStorage issues in MAUI
Not getting this in my emulator in Visual Studio, but after installing on my device, I have started getting these errors. I use SecureStorage for storing API logins, and tokens. Have been using them for ages, but this has come up all of a sudden. How do I fix this?
GetAsync ERROR: Xamarin.Google.Crypto.Tink.Shaded.Protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
at Java.Interop.JniEnvironment.StaticMethods.CallStaticObjectMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)
at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeObjectMethod(String encodedMember, JniArgumentValue* parameters)
at AndroidX.Security.Crypto.EncryptedSharedPreferences.Create(Context context, String fileName, MasterKey masterKey, PrefKeyEncryptionScheme prefKeyEncryptionScheme, PrefValueEncryptionScheme prefValueEncryptionScheme)
at Microsoft.Maui.Storage.SecureStorageImplementation.GetEncryptedSharedPreferences()
at Microsoft.Maui.Storage.SecureStorageImplementation.<>c__DisplayClass6_0.<PlatformGetAsync>b__0()
at System.Threading.Tasks.Task`1[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at MyApp.Services.MethodService.GetAsync(String path, Boolean auto)
--- End of managed Xamarin.Google.Crypto.Tink.Shaded.Protobuf.InvalidProtocolBufferException stack trace ---
com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
at com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite.parsePartialFrom(GeneratedMessageLite.java:1570)
at com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite.parseFrom(GeneratedMessageLite.java:1668)
at com.google.crypto.tink.proto.Keyset.parseFrom(Keyset.java:958)
at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.read(SharedPrefKeysetReader.java:84)
at com.google.crypto.tink.CleartextKeysetHandle.read(CleartextKeysetHandle.java:58)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.read(AndroidKeysetManager.java:328)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readOrGenerateNewKeyset(AndroidKeysetManager.java:287)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:238)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:155)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:120)
2 answers
Sort by: Most helpful
-
-
victor hernandez 0 Reputation points
2024-07-09T03:23:03.4633333+00:00 I think the MAUI team is working on it and the workaround is to set android:allowBackup to false https://github.com/dotnet/maui/issues/18230