Skip to content

App runs fine, unit tests report a MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) #24097

@sanderAtMaxdoro

Description

@sanderAtMaxdoro

The shared_preferences plugin only works for the app itself, not when running unit tests. To my mind this means that the

Exception report

package:flutter/src/services/platform_channel.dart 278:7  MethodChannel.invokeMethod
===== asynchronous gap ===========================
dart:async                                                _AsyncAwaitCompleter.completeError
package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
===== asynchronous gap ===========================
dart:async                                                _asyncThenWrapperHelper
package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
package:shared_preferences/shared_preferences.dart 25:27  SharedPreferences.getInstance
This test failed after it had already completed. Make sure to use [expectAsync]
or the [completes] matcher when testing async code.
package:flutter/src/services/platform_channel.dart 278:7  MethodChannel.invokeMethod
===== asynchronous gap ===========================
dart:async                                                _AsyncAwaitCompleter.completeError
package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
===== asynchronous gap ===========================
dart:async                                                _asyncThenWrapperHelper
package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
package:shared_preferences/shared_preferences.dart 25:27  SharedPreferences.getInstance
MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
package:flutter/src/services/platform_channel.dart 278:7  MethodChannel.invokeMethod
===== asynchronous gap ===========================
dart:async                                                _AsyncAwaitCompleter.completeError
package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
===== asynchronous gap ===========================
dart:async                                                _asyncThenWrapperHelper
package:flutter/src/services/platform_channel.dart        MethodChannel.invokeMethod
package:shared_preferences/shared_preferences.dart 25:27  SharedPreferences.getInstance
===== asynchronous gap ===========================
dart:async                                                _asyncThenWrapperHelper
test/model/Model_test.dart                                main.<fn>.<fn>

MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

Flutter doctor -v

✓] Flutter (Channel master, v0.10.3-pre.65, on Mac OS X 10.14.1 18B75, locale en-NL)
    • Flutter version 0.10.3-pre.65 at /Users/sandervanderwal/Developer/flutter
    • Framework revision 01c7081565 (7 days ago), 2018-10-31 21:12:51 -0700
    • Engine revision c79faed71c
    • Dart version 2.1.0 (build 2.1.0-dev.8.0 bf26f760b1)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    • Android SDK at /Users/sandervanderwal/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (2 available)
    • Turminder Xuss • ca4f8a0ddd55132ab42c253d7496b90a38b6b53c • ios • iOS 12.1
    • iPhone 6       • F1C23CB3-7C89-416E-87D0-5CCDC2C89254     • ios • iOS 12.1 (simulator)

• No issues found!

-- Pod update in the iOS folder

sanders-mbp:ios sandervanderwal$ pod update
Update all pods
Updating local specs repositories
  $ /usr/bin/git -C /Users/sandervanderwal/.cocoapods/repos/master fetch origin
  --progress
  remote: Enumerating objects: 19073, done.        
  remote: Counting objects: 100% (19073/19073), done.        
  remote: Compressing objects: 100% (346/346), done.        
  remote: Total 57973 (delta 18823), reused 18706 (delta 18706), pack-reused 38900        
  Receiving objects: 100% (57973/57973), 6.45 MiB | 8.49 MiB/s, done.
  Resolving deltas: 100% (39408/39408), completed with 4694 local objects.
  From https://github.com/CocoaPods/Specs
     1032228ce29..a21d78b8fba  master     -> origin/master
  $ /usr/bin/git -C /Users/sandervanderwal/.cocoapods/repos/master rev-parse
  --abbrev-ref HEAD
  master
  $ /usr/bin/git -C /Users/sandervanderwal/.cocoapods/repos/master reset --hard
  origin/master
  Checking out files: 100% (281500/281500), done.
  HEAD is now at a21d78b8fba [Add] WXWLaunchAdvertisedAdd 0.0.1
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 5913 and retry the command.

CocoaPods 1.6.0.beta.2 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.2

Analyzing dependencies
Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
Fetching podspec for `flutter_secure_storage` from `.symlinks/plugins/flutter_secure_storage/ios`
Fetching podspec for `image_picker` from `.symlinks/plugins/image_picker/ios`
Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
Downloading dependencies
Using Flutter (1.0.0)
Using flutter_secure_storage (3.1.1)
Using image_picker (0.0.1)
Using shared_preferences (0.0.1)
Generating Pods project
Integrating client project
Pod installation complete! There are 4 dependencies from the Podfile and 4 total pods installed.

[!] Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
sanders-mbp:ios sandervanderwal$ 

What is weird is that pub spec.yaml has shared_preferences: ^0.4.3
while pod update lists using shared_preferences (0.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsc: crashStack traces logged to the consolep: shared_preferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions