dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

MainActivity's OnCreate throws System.IO.FileNotFoundException #7195

Closed jayveedee closed 2 years ago

jayveedee commented 2 years ago

Description

I have no idea how this happens. I have a phone called Motorolla Edge 20, Android 12. Whenever I open the app I've created, OnCreate throws System.IO.FileNotFoundException (and swallows, so the app does not crash). This this did not happen before I either updated to Android 12 on my phone or in earlier versions of MAUI. One of the two, because I updated both some time ago and since it hasn't been working.

But with that said, this is only on my phone. The emulator works just fine, be it Android 11 or Android 12 (Pixel 5). So I'm not 100% sure if this has something to do with my phone. This also does not happen on a fresh MAUI install. Also something else, not sure if related but I use the WebAuthenticator from Essentials and when I try to login, the browser goes to the right site and I login, afterwards it tries to go back to the app but somehow opens another browser or something, it's very odd. This also works on the emulator but not on my phone.

Steps to Reproduce

  1. Start the project with my phone
  2. MainActivity's OnCreate throws exceptions

Version with bug

Release Candidate 3

Last version that worked well

Preview 14

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No response

Relevant log output

Thread started:  #2
Thread started:  #3
Thread started:  #4
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Serialization.Json.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Private.DataContractSerialization.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Serialization.Xml.dll
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/System.Runtime.Serialization.Json.dll [External]
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/System.Private.DataContractSerialization.dll [External]
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/System.Runtime.Serialization.Xml.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly en-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en-DK/System.Private.CoreLib.resources.dll
**System.IO.FileNotFoundException:** 'Loading...'

[monodroid-assembly] open_from_bundles: failed to load assembly en-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Serialization.Primitives.dll
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/System.Runtime.Serialization.Primitives.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly en-DK/System.Private.DataContractSerialization.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en-DK/System.Private.DataContractSerialization.resources.dll
**System.IO.FileNotFoundException:** ''

[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.DataContractSerialization.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.DataContractSerialization.resources.dll
**System.IO.FileNotFoundException:** ''

[monodroid-assembly] open_from_bundles: failed to load assembly IdentityModel.OidcClient.dll
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/IdentityModel.OidcClient.dll [External]
Thread started: <Thread Pool> #5
Thread started: .NET ThreadPool Gate #6
Thread started: <Thread Pool> #7
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Security.SecurityCrypto.dll
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/Xamarin.AndroidX.Security.SecurityCrypto.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.CoordinatorLayout.dll
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/Xamarin.AndroidX.CoordinatorLayout.dll [External]
[AndroidKeysetManager] keyset not found, will generate a new one
[AndroidKeysetManager] java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.readPref(SharedPrefKeysetReader.java:71)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.readEncrypted(SharedPrefKeysetReader.java:89)
[AndroidKeysetManager]  at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:116)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.read(AndroidKeysetManager.java:311)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readOrGenerateNewKeyset(AndroidKeysetManager.java:287)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:238)
[AndroidKeysetManager]  at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:155)
[AndroidKeysetManager]  at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:120)
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Lifecycle.LiveData.Core.dll
Loaded assembly: /data/data/com.exirpit.Totalview_Time/files/.__override__/Xamarin.AndroidX.Lifecycle.LiveData.Core.dll [External]
[AndroidKeysetManager] keyset not found, will generate a new one
[AndroidKeysetManager] java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_value_keyset__ does not exist
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.readPref(SharedPrefKeysetReader.java:71)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.readEncrypted(SharedPrefKeysetReader.java:89)
[AndroidKeysetManager]  at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:116)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.read(AndroidKeysetManager.java:311)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readOrGenerateNewKeyset(AndroidKeysetManager.java:287)
[AndroidKeysetManager]  at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:238)
[AndroidKeysetManager]  at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:160)
[AndroidKeysetManager]  at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:120)
jfversluis commented 2 years ago

It would be very helpful if you could somehow pinpoint further where this is coming from and put the relevant bits in a reproduction project. It seems you already have a hunch about the Essentials authenticator which might make sense as it seems to fail on trying to read/save some encrypted key.

ghost commented 2 years ago

Hi @jayveedee. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.