MissingPluginException(在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现)-现有解决方案不起作用-
Posted
技术标签:
【中文标题】MissingPluginException(在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现)-现有解决方案不起作用-【英文标题】:MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) -exist solutions didn't work- 【发布时间】:2021-01-24 09:03:30 【问题描述】:我正在构建一个使用这些包的应用程序
firebase_core:^0.5.0 firebase_analytics:^5.0.16 cloud_firestore: firebase_messaging:^7.0.0 flutter_local_notifications:^1.4.4+2 提供者:^4.3.1 http: ^0.12.2 reviews_slider:^1.0.5 flutter_screenutil: ^2.3.0 shared_preferences:^0.5.12 scroll_to_index: ^1.0.6 firebase_database: ^4.0.0 image_picker:^0.6.7+11 获取:^3.11.1在调试模式下一切正常,但是当我构建一个版本时,我得到了这个错误,我已经搜索了 3 天,我发现你需要这样做
flutter clean
pub get/ pub upgrade
然后它的工作原理在于一个魅力。但这对我不起作用
这里是 app/build.gradle 文件
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists())
localPropertiesFile.withReader('UTF-8') reader ->
localProperties.load(reader)
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null)
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null)
flutterVersionCode = '1'
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null)
flutterVersionName = '1.0'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists())
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android
compileSdkVersion 28
sourceSets
main.java.srcDirs += 'src/main/kotlin'
lintOptions
disable 'InvalidPackage'
checkReleaseBuilds false
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.zonedelivery.zonedelivery"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
signingConfigs
release
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
buildTypes
release
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debug
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-firestore-ktx:21.5.0'
implementation 'com.google.firebase:firebase-messaging:20.2.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
apply plugin: 'com.google.gms.google-services'
proguard-rules.pro 文件
## Flutter wrapper
-keep class io.flutter.app.** *;
-keep class io.flutter.plugin.** *;
-keep class io.flutter.util.** *;
-keep class io.flutter.view.** *;
-keep class io.flutter.** *;
-keep class io.flutter.plugins.** *;
-keep class io.flutter.plugins.sharedpreferences** *;
-dontwarn io.flutter.embedding.**
## Gson rules
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** *;
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class *
@com.google.gson.annotations.SerializedName <fields>;
## flutter_local_notification plugin rules
-keep class com.dexterous.** *;
【问题讨论】:
这能回答你的问题吗? Flutter: Unhandled exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) 【参考方案1】:尝试将 get_it 版本降级为: 获取它:^3.0.3 然后在命令窗口中写: 扑干净 然后重新安装应用程序
【讨论】:
还是同样的问题【参考方案2】:问题是缩小应用程序删除了一些重要的代码,所以它必须在 proguard 文件中解决所以我在 proguard 文件的底部添加了这一行
-keepclasseswithmembers class * *;
所以它保留所有类和函数而不删除任何代码 这个solution帮助了我
【讨论】:
以上是关于MissingPluginException(在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现)-现有解决方案不起作用-的主要内容,如果未能解决你的问题,请参考以下文章
MissingPluginException(未找到通道上的方法的实现)
GoogleMaps Flutter 插件 MissingPluginException
发布模式android中的MissingPluginException
尝试直接从 FLUTTER 发出呼叫:MissingPluginException(未找到方法 callNumber 的实现
android Unhandled Exception 上的 Flutter 运行错误:MissingPluginException(未找到方法的实现)
MissingPluginException(在通道 com.amazonaws.amplify/amplify 上找不到方法配置的实现)