Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android storage fix #134

Merged
merged 2 commits into from
Jul 17, 2022
Merged

Conversation

PiotrMitkowski
Copy link
Contributor

FlutterSecureStorage raises an exception on some newer Android OS versions, especially when running on Pixels. Here's an example of exception from Pixel 6 with Android 12 - it's raised when OAuth2Helper tries to access the token:

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
	at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
	at com.android.org.conscrypt.OpenSSLEvpCipher.doFinalInternal(OpenSSLEvpCipher.java:152)
	at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:374)
	at javax.crypto.Cipher.doFinal(Cipher.java:2055)
	at t6.b.b(Unknown Source:30)
	at s6.d.m(Unknown Source:11)
	at s6.d.t(Unknown Source:10)
	at s6.d.f(Unknown Source:0)
	at s6.d$b.run(Unknown Source:244)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.os.HandlerThread.run(HandlerThread.java:67)
, null). Error thrown null.
       at StandardMethodCodec.decodeEnvelope(message_codecs.dart:607)
       at MethodChannel._invokeMethod(platform_channel.dart:167)
       at SecureStorage.read(secure_storage.dart:14)
       at TokenStorage.getToken(token_storage.dart:25)
       at OAuth2Helper.getTokenFromStorage(oauth2_helper.dart:116)

There's a recommended fix under an issue in flutter_secure_storage repository, regarding the same problem: mogol/flutter_secure_storage#161 (comment). This PR applies the fix to oauth2_client

@okrad okrad merged commit 287c409 into teranetsrl:master Jul 17, 2022
@okrad
Copy link
Collaborator

okrad commented Jul 17, 2022

Thank you @PiotrMitkowski!

@PiotrMitkowski PiotrMitkowski deleted the android-storage-fix branch July 18, 2022 05:56
@maxhelskens
Copy link

I still have problems with the flutter_secure_storage on some android devices.

PlatformException(Exception encountered, read, java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.content.SharedPreferences.contains(java.lang.String)' on a null object reference at c5.a.b(Unknown Source:5) at c5.e$b.run(Unknown Source:221) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.os.HandlerThread.run(HandlerThread.java:67) , null). Error thrown Error while authenticating.

There's a recommended fix under an issue in flutter_secure_storage repository, regarding the same problem:
mogol/flutter_secure_storage#380 (comment)

I'll have to downgrade this package for now since it blocks certain users from using my app.

@okrad
Copy link
Collaborator

okrad commented Jan 26, 2023

HI @maxhelskens, thank you, looks like the latest FlutterSecureStorage release fixes that issue.
I'll update the package asap!

@okrad
Copy link
Collaborator

okrad commented Jan 26, 2023

@maxhelskens, I just published the new release with the updated dependencies. Can you check it out and see if your issue is solved?

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

Successfully merging this pull request may close these issues.

3 participants