I am banging my head around the internet for a long and could not figure out what is the problem and how to handle it. Please comment if you need any more details.
Problem: MissingPluginException - shared_preferences (No implementation found for method getAll on channel plugins.flutter.io/shared_preferences), image_picker (No implementation found for method pickImage), etc.
Below is my pubspec.yaml
name: appname
description: Short courses and live classes
publish_to: 'none'
version: 2.3.2+10
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.0
dio: ^4.0.0
provider: ^5.0.0
shared_preferences: ^2.0.5
image_picker: ^0.7.4
connectivity: ^3.0.3
flutter_image_compress: ^1.0.0
image_cropper: ^1.3.1
flutter_svg: ^0.19.1
dotted_border: ^1.0.7
carousel_slider: ^3.0.0
after_layout: ^1.0.7+2
url_launcher: ^6.0.3
esys_flutter_share: ^1.0.2
android_play_install_referrer: ^0.1.1
pull_to_refresh: ^1.6.4
intl: ^0.17.0
hashtagtext: ^0.0.1
flutter_branch_sdk: ^3.0.0 <---- If I remove this, everything works as expected
flutter_staggered_grid_view: ^0.3.4
photo_view: ^0.11.1
agora_rtc_engine: ^3.3.2
timeago: ^3.0.2
chewie: ^1.0.0
video_player: ^2.1.0
cashfree_pg: 1.2.2+16
awesome_dialog: ^1.3.2
firebase_core: ^1.0.2
firebase_auth: 1.0.1
firebase_crashlytics: 1.0.0
firebase_messaging: 9.1.0
#permission_handler: 5.1.0+2
#agora_rtm: ^0.9.14
#line_icons: 1.3.2
#launch_review: ^2.0.0
#shimmer: ^1.1.2
#flutter_slidable: ^0.5.7
#flutter_instagram_image_picker: ^0.3.1
#uuid: ^2.0.4
#device_info: ^1.0.0
#wakelock: ^0.2.1+1
#share: ^0.6.5+4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/images/
- assets/languages/
fonts:
- family: PingFang
fonts:
- asset: assets/fonts/PingFang-SC-Regular.ttf
- family: OpenSans
fonts:
- asset: assets/fonts/OpenSans-Regular.ttf
I tried the below solutions:
Solution #1 - https://stackoverflow.com/a/66417139/2456838
Solution #2 - Added SharedPreferences.setMockInitialValues({});
to the main method. But all values are returned null on retrival from local storage.
Solution #3 (Working) - If I remove flutter_branch_sdk
dependency everything works as expected. I tried all the versions of flutter_branch_sdk
but none worked.
Other solutions - Updated the flutter, dart, Android Studio, etc. Upgraded all the dependencies to major-version. Created a new project with the latest versions of Gradle and all dependencies.
Below is my flutter doctor
jdpawar@JD-MBP revofy % flutter doctor --verbose
[✓] Flutter (Channel stable, 2.0.3, on Mac OS X 10.15.7 19H524 darwin-x64, locale en-GB)
• Flutter version 2.0.3 at /Users/jdpawar/Projects/flutter-sdk
• Framework revision 4d7946a68d (2 weeks ago), 2021-03-18 17:24:33 -0700
• Engine revision 3459eb2436
• Dart version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/jdpawar/Library/Android/sdk
• Platform android-30, build-tools 29.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_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.55.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
[✓] Connected device (2 available)
• Nokia 6 1 (mobile) • PL2GAR4820502886 • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.114
• No issues found!
Edit 1:
I have tried running the code on Mi A1, Nokia 5.1, Simulator - Pixel 2 Q, Pixel 3 XL, etc.
Below is my AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.revofy">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="revofy"
requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>