flutter_secure_storage: App built in release mode does not start
My app built in release mode does not get past the launch screen. When built in debug mode, everything works fine.
In my main
method, I have the following code that will check if a previous login session exists so the user does not need to log in again each time.
Future<null> main(List<String> args) async {
// ...
final storage = FlutterSecureStorage();
final hasExisting = await storage.read(key: "isExisting");
// ...
runApp(MyApp(hasExisting: hasExisting));
}
And I can confirm that this plugin is the one causing the problem because when I change the code to the following
Future<null> main(List<String> args) async {
// ...
// final storage = FlutterSecureStorage();
// final hasExisting = await storage.read(key: "isExisting");
final hasExisting = false;
// ...
runApp(MyApp(hasExisting: hasExisting));
}
Everything works, but of course the desired function is not the same.
I can confirm it was working as of March 5, but it no longer does.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 16
- Comments: 23 (1 by maintainers)
I fixed this issue by executing
await storage.deleteAll();
only once, after setting backups off:I was having the same problem as above. The easy fix for me was to clear storage for the app.
Settings -> Apps -> Your App -> Storage -> Clear Storage
I have a similar issue. After installing .apk file and launching application on a device, it uses
FlutterSecureStorage
to get information if user is logged in or not, along with other values. I expect null during first run, of course, butstorage.read(key)
seams to fail before returning any value.Added backup tags in main/AndroidManifest.xml
Added deleting keys on startup
Tried with
FlutterSecureStorage v.3.3.3
andFlutterSecureStorage v.3.2.0
, but there was no change. I checked SDK version of my device (Honor 10) - 29. Also checked on other device (Samsung Galaxy S9+), but the issue also occurs.Running
flutter run --release
causes warnings:and error:
but successfully installs application on emulator and everything works as expected. The problem is when I install application on physical device. To generate .apk I use
flutter build apk --release
and install using app-release.apk file as stated in build log:My
flutter doctor -v
I tried to make sure my project is migrated to AndroidX and got a message:
No Usages Found in the Project
.I don’t have any more ideas, could you help me?
more info: running
flutter run --release
starts the app and it gets stuck on the launch screen with the following output to the console:@juliansteenbakker I am also facing problem of PlatformException when I am downloading installing aab from market. Yes, the clear storage do the thing, but that’s incorrect behavior. Huawei Mate 20 light.
What is still unclear to me is, if this is happening “in the wild” or has something to do with development. Because on one of my new devices i am developing on this was happening again. But i am unable to reproduce it. It just suddenly happened. But i can imagine it has something to do with rapid deployment where the app is starting and all of the sudden a new version is deployed right in between where something with the en/decryption is happening and some keys get only stored half way because the app is restarting/redeploying. It never occurred on devices that are there only for testing not developing.
One thing i do now is to make a “fake” call to the storage (read some useless key) at the start of the application and
.deleteAll()
if an exception is thrown. This would potentially delete all the user data, but it is better than the other way, because the app is unusable if this happens. We “just” store credentials inside it, that could easily be reentered – its just for convenience. But its still unfortunate because i don’t know if our client plans to use it for something else in the future.Having the same Problem, but not only with release, also in “debug”. One major thing i can remember is, that i updated the toolchain to (Android toolchain - develop for Android devices (Android SDK version 28.0.3) very recently and not much else.