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

MissingPluginException(No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage) #83

Closed
paul-hammant opened this issue Sep 19, 2019 · 44 comments

Comments

@paul-hammant
Copy link

flutter doctor -v

[✓] Flutter (Channel unknown, v1.7.8+hotfix.3, on Mac OS X 10.14.6 18G95, locale en-GB)
    • Flutter version 1.7.8+hotfix.3 at /Users/paul/flutter
    • Framework revision b712a172f9 (2 months ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/paul/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/paul/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/paul/Library/Android/sdk
    • Java binary at: /Users/paul/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.5

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Users/paul/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents
    • Flutter plugin version 38.2.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
    • IntelliJ at /Users/paul/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 35.3.2
    • Dart plugin version 191.7019

[✓] Connected device (3 available)
    • Android SDK built for x86 64 • emulator-5554 • android-x64    • Android 8.0.0 (API 26) (emulator)
    • macOS                        • macOS         • darwin-x64     • Mac OS X 10.14.6 18G95
    • web                          • web           • web-javascript • Google Chrome 76.0.3809.132 


• No issues found!

Stack trace during scripted build/launch (MacOS 10.14.6, homebrew up to date):

Restarted application in 2,710ms.
Hot Restarted!
I/flutter (23832): Start Integration App...
I/flutter (23832): Error caught by Crashlytics plugin <recordError>:
I/flutter (23832): MissingPluginException(No implementation found for method readAll on channel plugins.it_nomads.com/flutter_secure_storage)
I/flutter (23832):
I/flutter (23832): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
I/flutter (23832): <asynchronous suspension>
I/flutter (23832): #1      FlutterSecureStorage.readAll (package:flutter_secure_storage/flutter_secure_storage.dart:40:40)
I/flutter (23832): <asynchronous suspension>
I/flutter (23832): #2      PreferencesService.loadFromStorage (package:myapp/data/services/preference_service.dart:37:33)
I/flutter (23832): <asynchronous suspension>
I/flutter (23832): #3      main (package:myapp/main.dart:109:30)

Version in pubspec.yaml -> v3.2.1+1

Building on API 28, deploying to API 26 .... could that be the issue? There's a minimum supported version? Should it fail more gracefully?

@rekire
Copy link

rekire commented Sep 22, 2019

The solution based on #71 (comment) is to uninstall the app. Works for me.

@gyorfiavarlehel
Copy link

I have a similar problem. I would like to access the secure storage while the app is in the background. I use the workmanager package.

Initialization:
Workmanager.initialize(callbackDispatcher, isInDebugMode: true);

The callbackDispatcher method:

void callbackDispatcher() {
  Workmanager.executeTask((task, inputData) async {
    switch (task) {
      case Workmanager.iOSBackgroundTask:
        try {
          var secureStorage = FlutterSecureStorage();
          String value = await secureStorage.read(key: "aKey");
          Log.i("callbackDispatcher ... $value.");
        } catch (e, s) {
          Log.e("$e ... $s.");
        }
        break;
    }
    return Future.value(true);
  });
}

However, I always receive the following exception when I simulate the background fetch.

MissingPluginException(No implementation found for method read on channel plugins.it_nomads.com/flutter_secure_storage) ... 
#0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)<…>
#1      FlutterSecureStorage.read (package:flutter_secure_storage/flutter_secure_storage.dart:29:41)<…>
#2      callbackDispatcher.<anonymous closure> (package:myapp/src/app.dart:92:46)<…>
#3      Workmanager.executeTask.<anonymous closure> (package:workmanager/src/workmanager.dart:80:28)<…>
#4      MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:402:55)<…>
#5      MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:370:54)<…>
#6      _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binding.dart:200:33)<…>
#7      _invoke3.<anonymous closure> (dart:ui/hooks.dart:303:15)<…>
#8      _rootRun (dart:async/zone.dart:1124:13)<…>
#9      _CustomZone.run (dart:async/zone.dart:1021:19)<…>
#10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)<…>
#11     _invoke3 (dart:ui/hooks.dart:302:10)<…>
#12     _dispatchPlatformMessage (dart:ui/hooks.dart:162:5)<…>

@gyorfiavarlehel
Copy link

It turned out that most probably the problem is that the plugin does not register itself when it has no Activity Context. Can you please provide a method to register the plugin in the application context to be able to access it without UI.

Work manager issue

@marciioluucas
Copy link

Uninstalling and installing the app works for me

@PhloxDev
Copy link

thanks, this was affecting me in widget test

@jkyon
Copy link

jkyon commented Feb 20, 2020

Hi, I have installed this plugin, and I have the same issue. I tried unistalling the app, but it does not work.
Is there a workaround for this issue?

thank you in advance

@gyorfiavarlehel
Copy link

For me the error also disappeared. Most probably because I cleaned everything and/or uninstalled and reinstalled the app. I don't know what could cause that error. Fortunately it works properly now.

Please note that sometimes the installed plugin version is not in sync with the pubspec.yaml file. You can check the pub-cache (for me it is ~/.pub-cache/hosted/pub.dartlang.org) folder to check what version is installed.

In pubspec.yaml:
flutter_secure_storage: ^3.3.1+1

@shashikantshaale
Copy link

Re installing and flutter clean worked for me too

@smvcdev
Copy link

smvcdev commented Apr 6, 2020

Uninstalling/reinstalling the app works -- make sure you set your minSdkVersion in your app/build.gradle to 18 or else it will fail on reinstall

@yousifAlneamy
Copy link

I'm facing this problem with android 4.4.2 (Samsung Galaxy Grand 2). Also, the same problem with Galaxy Tabs reported by my app users

@kele82
Copy link

kele82 commented May 5, 2020

Same here, user reported this problem on Moto e5, Android 8.0

@dsp1589
Copy link

dsp1589 commented May 17, 2020

facing problem in google pixel 3a.

@hmawla
Copy link
Contributor

hmawla commented Jun 1, 2020

Same problem here with Galaxy J7 2015 android 6.0.1

@hmawla
Copy link
Contributor

hmawla commented Jun 1, 2020

Check here #131

@hartmannj
Copy link

Same here, several users with different devices and Android versions are having this issue. Roughly 5% of our users are affected after an app upgrade which is quite significant.

@etEthiopia
Copy link

flutter doctor -v

[✓] Flutter (Channel unknown, v1.7.8+hotfix.3, on Mac OS X 10.14.6 18G95, locale en-GB)
    • Flutter version 1.7.8+hotfix.3 at /Users/paul/flutter
    • Framework revision b712a172f9 (2 months ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/paul/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/paul/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/paul/Library/Android/sdk
    • Java binary at: /Users/paul/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.5

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Users/paul/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents
    • Flutter plugin version 38.2.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
    • IntelliJ at /Users/paul/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 35.3.2
    • Dart plugin version 191.7019

[✓] Connected device (3 available)
    • Android SDK built for x86 64 • emulator-5554 • android-x64    • Android 8.0.0 (API 26) (emulator)
    • macOS                        • macOS         • darwin-x64     • Mac OS X 10.14.6 18G95
    • web                          • web           • web-javascript • Google Chrome 76.0.3809.132 


• No issues found!

Stack trace during scripted build/launch (MacOS 10.14.6, homebrew up to date):

Restarted application in 2,710ms.
Hot Restarted!
I/flutter (23832): Start Integration App...
I/flutter (23832): Error caught by Crashlytics plugin <recordError>:
I/flutter (23832): MissingPluginException(No implementation found for method readAll on channel plugins.it_nomads.com/flutter_secure_storage)
I/flutter (23832):
I/flutter (23832): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
I/flutter (23832): <asynchronous suspension>
I/flutter (23832): #1      FlutterSecureStorage.readAll (package:flutter_secure_storage/flutter_secure_storage.dart:40:40)
I/flutter (23832): <asynchronous suspension>
I/flutter (23832): #2      PreferencesService.loadFromStorage (package:myapp/data/services/preference_service.dart:37:33)
I/flutter (23832): <asynchronous suspension>
I/flutter (23832): #3      main (package:myapp/main.dart:109:30)

Version in pubspec.yaml -> v3.2.1+1

Building on API 28, deploying to API 26 .... could that be the issue? There's a minimum supported version? Should it fail more gracefully?

Yes Use Minimum SDK 18

@sh3rlock97
Copy link

It turned out that most probably the problem is that the plugin does not register itself when it has no Activity Context. Can you please provide a method to register the plugin in the application context to be able to access it without UI.

Work manager issue

I've got the same issue, could you fix it?

@gyorfiavarlehel
Copy link

It turned out that most probably the problem is that the plugin does not register itself when it has no Activity Context. Can you please provide a method to register the plugin in the application context to be able to access it without UI.
Work manager issue

I've got the same issue, could you fix it?

Please see my comment on 4 Mar. The error disappeared automatically.

@maxisme
Copy link

maxisme commented Jul 9, 2020

Tried:

$ rm -rf ~/.pub-cache/hosted/pub.dartlang.org/*
$ flutter packages get 
$ flutter clean
$ flutter run -d macos

Still the same error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method read on channel plugins.it_nomads.com/flutter_secure_storage)

@sh3rlock97
Copy link

@maxisme Are dou running it in Background?

@maxisme
Copy link

maxisme commented Jul 9, 2020

I just thought that it would work with MacOS if it worked with iOS turns out it doesn't so I used the dependency from this PR - #91 (not sure why it hasn't been merged) :

  flutter_secure_storage:
    git:
      url: git://github.com/openresearch/flutter_secure_storage.git
      ref: feature/macos_support

Now it works great.

@hadi-norouzi
Copy link

I have the same issue on samsung note 3 , android 5

@8fdafs2
Copy link

8fdafs2 commented Aug 3, 2020

Everything is fine when I use 'flutter run --release' to run the app on my android device.
However, if I use 'flutter build apk' to build an apk then transfer it to my android device and run it, the problem arises.

My devices are of Android 6 and Android 10

Deleted my local pub cache and regenerated it using 'flutter pub get', still no improvements.

@KoheiKanagu
Copy link

@8fdafs2
Try the no-shrink flag.
I resolved the MissingPluginException with the no-shrink flag.
https://flutter.dev/docs/deployment/android#shrinking-your-code-with-r8

@8fdafs2
Copy link

8fdafs2 commented Aug 3, 2020

@8fdafs2
Try the no-shrink flag.
I resolved the MissingPluginException with the no-shrink flag.
https://flutter.dev/docs/deployment/android#shrinking-your-code-with-r8

Many thanks!
The problem disappears by using this workaround!
But I think this is not a final solution as people may still need to 'shrink code'.
And I am worrying about whether or not Google will try to shrink the uploaded appbundle automatically to re-introduce this issue.
Anyway, some progress has been made!

@wilyanto
Copy link

wilyanto commented Feb 1, 2021

After few hours of surfing. Finally SOLVED for me. Here is what I found out.

If you are calling flutter_secure_storage (or any packages) method in background service (as example, when you are using notification onBackgroundMessage). This exception occurred because usually our plugin registered at main.dart in foreground, but if we are calling our plugin's method in background we need to manually registered our plugin in our app/src/main/[kotlin/java]/.../Application.[java or kt].

Inside the Application.java or Application.kt

image

After done that, do flutter run again. Hope it helps!

@DhavalRKansara
Copy link

I am facing the same issue while I run my app for the flutter web or mac os... for the mobile app, it's working fine...

@KoheiKanagu
Copy link

@DhavalRKansara macOS and Web are not supported.
https://pub.dev/packages/flutter_secure_storage

スクリーンショット 2021-04-24 21 53 14

@wilyanto
Copy link

wilyanto commented Apr 26, 2021

I am facing the same issue while I run my app for the flutter web or mac os... for the mobile app, it's working fine...

If you are running in web-based platform, use localstorage library.

@DhavalRKansara
Copy link

@DhavalRKansara macOS and Web are not supported.
https://pub.dev/packages/flutter_secure_storage

スクリーンショット 2021-04-24 21 53 14

@KoheiKanagu Agreed that in 4.1.0 they don't have support for the web and macOS but is there any planning to provide support for the macOS and web in the future?

@abhinavsingh
Copy link

Something as simple as this fails to work for me.

test('secure storage', () async {
    final storage = new FlutterSecureStorage();
    String? value = await storage.read(key: "access");
    expect(value, "");
  });
MissingPluginException(No implementation found for method read on channel plugins.it_nomads.com/flutter_secure_storage)

@mogol
Copy link
Collaborator

mogol commented May 13, 2021 via email

@abhinavsingh
Copy link

It should not work. No plugins are available in test environment. You can mocks for test purpose Sent from ProtonMail for iOS

On Thu, May 13, 2021 at 21:55, Abhinav Singh @.***> wrote: Something as simple as this fails to work for me. test('secure storage', () async { final storage = new FlutterSecureStorage(); String? value = await storage.read(key: "access"); expect(value, ""); }); MissingPluginException(No implementation found for method read on channel plugins.it_nomads.com/flutter_secure_storage) — You are receiving this because you are subscribed to this thread. Reply to this email directly, [view it on GitHub](#83 (comment)), or unsubscribe.

Thank you for quick response. We'll go ahead and add our own mocks.

But in future won't it be possible to add something as simple as SharedPreferences.setMockInitialValues({});.

Thank you!!!

@cyberboy2012
Copy link

hi, I am getting the error below, how can I solve it.
error: package com.it_nomads.fluttersecurestorage does not exist flutterEngine.getPlugins().add(new com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin());

@juliansteenbakker
Copy link
Owner

Duplicate of #71

@juliansteenbakker juliansteenbakker marked this as a duplicate of #71 Jul 27, 2021
@jiangxiaoqiang
Copy link

upgrade to 5.0.0 will fix this problem.

@skucukmidil
Copy link

Firstly, I am sorry if I am mistaken to giving answer to this issue but I was getting same error for trying to write unit test for my local project. So if I am not mistaken, we can't use the secure storage directly at tests. For this reason I write a simple mixin for my mock data source. If any one needs it, you can use it.

`mixin MockSecureStorageMixin{
///We can't use secure storage at test time with our mock class so for that reason,
///we can use this mixin with our mock class.
///class CustomMockClass with MockSecureStorageMixin
///if we will test a model with fromJson, we can do this:
///test("bla bla", (){
/// final TestModelType _testModel=....;
/// mockObject.mockSetSecureStorageTestValue(key, json.encode(_testModel.toJson()));
///
///});
final Map<String, String> _mockSecureStorageValueMap={};

///You can change the test delay based on your tests.
final Duration _mockSecureStorageTestDelay=const Duration(milliseconds: 50);

Future<String?> mockGetSecureStorageTestValue(dynamic key)async{
await Future.delayed(_mockSecureStorageTestDelay);
return _mockSecureStorageValueMap[key.toString()];
}

Future mockSetSecureStorageTestValue(dynamic key, dynamic value)async{
await Future.delayed(_mockSecureStorageTestDelay);
_mockSecureStorageValueMap.addAll({key.toString():value.toString()});
return true;
}

Future<String?> mockSecureStorageTestValue(dynamic key)async{
await Future.delayed(_mockSecureStorageTestDelay);
if(_mockSecureStorageValueMap.containsKey(key.toString())){
_mockSecureStorageValueMap.remove(key.toString());
}
}

Future mockSecureStorageClearer()async{
await Future.delayed(_mockSecureStorageTestDelay);
_mockSecureStorageValueMap.clear();
}
}`

@HmzEzh
Copy link

HmzEzh commented Aug 3, 2022

Uninstalling and installing the app works for me

@felipecastrosales
Copy link

what is the exact solution for this in a test? I would like to add coverage on that.

@nikhil-s-b
Copy link

@felipecastrosales Did you find a solution for the test?

@nikhil-s-b
Copy link

nikhil-s-b commented Dec 1, 2022

Yeah @nikhil-s-b, I create in:

I hope it helps. :)

@felipecastrosales This is great! Thanks

@sgehrman
Copy link

doesn't work. I'm on web. what is the solution?

@wfgm5k2d
Copy link

Oddly enough, deleting the application also helped me
I develop on macOS and use the simulator built into Android Studio
Simulator included on Iphone 15 Pro Max
My steps to fix it

  1. Stop the application
  2. Turn off the emulator
  3. flutter clean
  4. flutter upgrade
  5. Pull back all dependencies (Android Studio suggested doing this via a button)

I checked, everything works

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

No branches or pull requests