mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.13k stars 378 forks source link

FATAL EXCEPTION: com.it_nomads.fluttersecurestorage.worker #802

Open SimonErich opened 1 month ago

SimonErich commented 1 month ago

Hello,

I just updated our app to flutter 3.24.1 and flutter_secure_storage 9.2.2, but when I run the app in release mode I get:

➜  app git:(main) ✗ flutter run --release --flavor=production
Launching lib/main.dart on SM S918B in release mode...
I/flutter (17402): STARTING WIDGET UPDATE
Running Gradle task 'assembleProductionRelease'...                150.0s
✓ Built build/app/outputs/flutter-apk/app-production-release.apk (40.9MB)
Installing build/app/outputs/flutter-apk/app-production-release.apk...      2,544ms

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
E/AndroidRuntime(17849): FATAL EXCEPTION: com.it_nomads.fluttersecurestorage.worker
E/AndroidRuntime(17849): Process: com.my.example, PID: 17849
E/AndroidRuntime(17849): java.lang.ExceptionInInitializerError
E/AndroidRuntime(17849):        at L7.f.a(DeterministicAeadConfig.java:20)
E/AndroidRuntime(17849):        at L7.f.<clinit>(DeterministicAeadConfig.java:8)
E/AndroidRuntime(17849):        at androidx.security.crypto.a.a(EncryptedSharedPreferences.java:5)
E/AndroidRuntime(17849):        at d9.a.j(FlutterSecureStorage.java:53)
E/AndroidRuntime(17849):        at d9.a.f(FlutterSecureStorage.java:35)
E/AndroidRuntime(17849):        at d9.a.b(FlutterSecureStorage.java:1)
E/AndroidRuntime(17849):        at d9.d$b.run(FlutterSecureStoragePlugin.java:226)
E/AndroidRuntime(17849):        at android.os.Handler.handleCallback(Handler.java:958)
E/AndroidRuntime(17849):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17849):        at android.os.Looper.loopOnce(Looper.java:230)
E/AndroidRuntime(17849):        at android.os.Looper.loop(Looper.java:319)
E/AndroidRuntime(17849):        at android.os.HandlerThread.run(HandlerThread.java:67)
E/AndroidRuntime(17849): Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: S7.I.values []
E/AndroidRuntime(17849):        at java.lang.Enum.enumValues(Enum.java:313)
E/AndroidRuntime(17849):        at java.lang.Enum.-$$Nest$smenumValues(Unknown Source:0)
E/AndroidRuntime(17849):        at java.lang.Enum$1.create(Enum.java:320)
E/AndroidRuntime(17849):        at java.lang.Enum$1.create(Enum.java:318)
E/AndroidRuntime(17849):        at libcore.util.BasicLruCache.get(BasicLruCache.java:63)
E/AndroidRuntime(17849):        at java.lang.Enum.getSharedConstants(Enum.java:332)
E/AndroidRuntime(17849):        at java.lang.Class.getEnumConstantsShared(Class.java:4118)
E/AndroidRuntime(17849):        at java.util.EnumMap.getKeyUniverse(EnumMap.java:749)
E/AndroidRuntime(17849):        at java.util.EnumMap.<init>(EnumMap.java:136)
E/AndroidRuntime(17849):        at L7.e.<clinit>(AesSivProtoSerialization.java:76)
E/AndroidRuntime(17849):        ... 12 more
E/AndroidRuntime(17849): Caused by: java.lang.NoSuchMethodException: S7.I.values []
E/AndroidRuntime(17849):        at java.lang.Class.getMethod(Class.java:2950)
E/AndroidRuntime(17849):        at java.lang.Class.getDeclaredMethod(Class.java:2929)
E/AndroidRuntime(17849):        at java.lang.Enum.enumValues(Enum.java:310)
E/AndroidRuntime(17849):        ... 21 more

Did anybody encounter this or is there a fix for it? Are there any specific proguard rules I should add?

The error appears whenever I call a flutter secture storage method.

Thanks

SimonErich commented 1 month ago

Just tried to build with minifyEnabled false and then it works perfectly fine.

Tried to add

-keep class androidx.security.crypto.** { *; }
-keep class com.it_nomads.fluttersecurestorage.** { *; }

to the proguard rules, but that does not seem to be enough in minify mode.