如何解决MissingPluginException在通道plugins.flutter.io/shared_preferences上未找到方法getAll的实现-现有解决方案不起作用-
我正在构建一个使用这些软件包的应用程序
- 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
- 图片选择器:^ 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,'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.** { *; }
解决方法
尝试将get_it版本降级为: get_it:^ 3.0.3 然后在命令窗口中输入: 扑扑干净 然后重新安装该应用
,问题是缩小的应用程序删除了一些重要的代码,因此必须在proguard文件中解决,所以我在proguard文件的底部添加了这一行
-keepclasseswithmembers class * {*;}
因此可以保留所有类和功能,而无需删除任何代码 solution帮了我
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。