jonataslaw / get_storage

A fast, extra light and synchronous key-value storage to Get framework
MIT License
357 stars 81 forks source link

MissingPluginException #33

Open psenechal opened 3 years ago

psenechal commented 3 years ago

Can't seem to figure this one out. I don't have any problems launching this on an iOS simulator, but launching on either an Android API 29 or API 30 simulator causes the following error and a blank screen. If I comment out await GetStorage.init(); in my code, the app launches, although without storage capabilities. Any ideas on what might be going wrong?

STACK TRACE

E/flutter ( 8379): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
E/flutter ( 8379): #0      GetStorage._init (package:get_storage/src/storage_impl.dart:47:7)
E/flutter ( 8379): <asynchronous suspension>
E/flutter ( 8379): #1      new GetStorage._internal.<anonymous closure> (package:get_storage/src/storage_impl.dart:27:13)
E/flutter ( 8379): #2      new Future.<anonymous closure> (dart:async/future.dart:175:37)
E/flutter ( 8379): #3      _rootRun (dart:async/zone.dart:1182:47)
E/flutter ( 8379): #4      _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 8379): #5      _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 8379): #6      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter ( 8379): #7      _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 8379): #8      _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 8379): #9      _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
E/flutter ( 8379): #10     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8379): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter ( 8379): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter ( 8379): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

pubspec.yaml

name: got_brix
description: Winemakers Management & Cellar Tracking Tool

publish_to: 'none'

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: 0.14.3
  crypto: 2.1.5
  cupertino_icons: 1.0.0
  firebase_analytics: 6.2.0
  firebase_auth: 0.18.3
  firebase_core: 0.5.2
  flutter_facebook_auth: 1.0.0+3
  flutter_svg: 0.19.1
  font_awesome_flutter: '>= 4.7.0'
  get: 3.17.1
  get_storage: 1.3.2
  google_sign_in: 4.5.6
  sign_in_with_apple: 2.5.4
  video_player: 1.0.0

dependency_overrides:
  font_awesome_flutter:
    path: '../font_awesome_flutter'

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true
  assets:
    - assets/images/
    - assets/videos/

I tried adding path_provider as a dependency (yes, did a clean and pub get and rebooted several times) and nothing changed

I'm on Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-US)

Any suggestions are greatly appreciated. Thanks!

zeroprofit commented 3 years ago

Try

await GetStorage().init('testx');

instead of

await GetStorage().init();

psenechal commented 3 years ago

Unfortunately, making that alteration didn’t change the outcome. I believe there is another issue here on GitHub with the same issue and a few more posters. I might join that issue so it’s all together. They are also having the same issue with the Android build while iOS continues to work fine. Thanks

qianxuechao commented 3 years ago

http://blog.z7ge.com/archives/flutter-missingpluginexception-bu-yao-huang 希望能帮到你

Manjunath-VM commented 3 years ago

Any one facing this issue .please let me know how to fix it.

E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)

0 GetStorage._init (package:get_storage/src/storage_impl.dart:50)

<asynchronous suspension>
#1      new GetStorage._internal.<anonymous closure> (package:get_storage/src/storage_impl.dart:28)
<asynchronous suspension>
#2      LocalStorage.initLocalStorage (package:medeva/utility/local_storage.dart:15)
<asynchronous suspension>
mozaffari commented 3 years ago

this issue is driving me crazy, still not able to fix

mozaffari commented 3 years ago

I finally solved the problem and it seems @psenechal has the same issue.

the problem is to add the flutter_facebook_auth package but not completing the flutter_facebook_auth package setup.

the solution is to temporarily comment the await GetStorage.init(); then complete the setup of flutter_facebook_auth. then you will not have the error

_just don't add flutter_facebook_auth in pubspec.yaml if you are not using it or first complete the flutter_facebook_auth setup then add getstorage to pubspec.yaml

I know it is pretty wired but that is the problem I had.

jonataslaw commented 3 years ago

related https://github.com/flutter/flutter/issues/62006

darkfrog26 commented 3 years ago

Any updates on this? I'm experiencing the same problem in my app. Not sure what @mozaffari is referring to, but I'm not using Facebook Auth in my app.

2021-04-14 12:00:56.035 23392-23418/? E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
    #0      GetStorage._init (package:get_storage/src/storage_impl.dart:47)
    <asynchronous suspension>
    #1      new GetStorage._internal.<anonymous closure> (package:get_storage/src/storage_impl.dart:28)
    <asynchronous suspension>
    #2      main (package:food_alert/main.dart:13)
    <asynchronous suspension>
mozaffari commented 3 years ago

@darkfrog26 Most of the time there is another package causing this issue, in my case I commented out the flutter_facebook_auth in my dependencies, and surprisingly I don't have the issue now.

I had the issue even when with the hive.

darkfrog26 commented 3 years ago

Not sure if this is helpful to anyone, but downgrading to Gradle 3.5.0 (classpath 'com.android.tools.build:gradle:3.5.0') and an earlier version of NDK (20.1....) was able to resolve my issue.

deepss1 commented 3 years ago

I finally solved the problem and it seems @psenechal has the same issue.

the problem is to add the flutter_facebook_auth package but not completing the flutter_facebook_auth package setup.

the solution is to temporarily comment the await GetStorage.init(); then complete the setup of flutter_facebook_auth. then you will not have the error

_just don't add flutter_facebook_auth in pubspec.yaml if you are not using it or first complete the flutter_facebook_auth setup then add getstorage to pubspec.yaml

I know it is pretty wired but that is the problem I had.

This actually solved the problem. Quite strange but yes.

If you are not using facebook authentication in your app, it might be possible that there's some other plugin which uses path_provider or something.

Try overriding path_provider. I haven't tried this but it might work.

narendra02031997 commented 3 years ago

I finally solved the problem and it seems @psenechal has the same issue.

the problem is to add the flutter_facebook_auth package but not completing the flutter_facebook_auth package setup.

the solution is to temporarily comment the await GetStorage.init(); then complete the setup of flutter_facebook_auth. then you will not have the error

_just don't add flutter_facebook_auth in pubspec.yaml if you are not using it or first complete the flutter_facebook_auth setup then add getstorage to pubspec.yaml

I know it is pretty wired but that is the problem I had.

Thanks you saved my lots of time

tejpalSinghRathore commented 1 year ago

this can be solved by putting some changes in build.gradle under

android { buildTypes { getByName("release") { // Enables code shrinking, obfuscation, and optimization for only // your project's release build type. isMinifyEnabled = true

        // Enables resource shrinking, which is performed by the
        // Android Gradle plugin.
        isShrinkResources = true

        // Includes the default ProGuard rules files that are packaged with
        // the Android Gradle plugin. To learn more, go to the section about
        // R8 configuration files.
        proguardFiles(
            getDefaultProguardFile("proguard-android-optimize.txt"),
            "proguard-rules.pro"
        )
    }
}
...

}

reference: https://developer.android.com/studio/build/shrink-code#kts