Приложение My Flutter показывает пустой белый экран со следующими ошибками при создании подписанной версии --release для запуска на физическом устройстве:
W/FlutterActivity(24374): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.a@10d90e5) but could not find and invoke the GeneratedPluginRegistrant.
E/flutter (24374): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
Все работает нормально при отладке.
Вот как выглядят мои различные файлы:
MainActivity.kt
package my.app.id
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
Application.kt
Это было сделано, потому что обмен сообщениями firebase не работал, и рекомендовался везде в Интернете, и исправил мои проблемы, по крайней мере, в режиме отладки.
package my.app.id
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
override fun registerWith(registry: PluginRegistry) {
FirebaseCloudMessagingPluginRegistrant.registerWith(registry)
}
}
FirebaseCloudMessagingPluginRegistrant.kt
package my.app.id
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
class FirebaseCloudMessagingPluginRegistrant {
companion object {
fun registerWith(registry: PluginRegistry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
}
fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
val key = FirebaseCloudMessagingPluginRegistrant::class.java.name
if (registry.hasPlugin(key)) {
return true
}
registry.registrarFor(key)
return false
}
}
}
AndroidManifest. xml (его части)
...
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".Application"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
...
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
...
<meta-data
android:name="flutterEmbedding"
android:value="2" />
build.gradle
defaultConfig {
applicationId "my.app.id"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
...
buildTypes {
release {
minifyEnabled true
}
}
...
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version'
implementation 'com.google.firebase:firebase-messaging:20.2.3'
implementation 'com.google.firebase:firebase-auth:19.3.2'
}
I ' Я перепробовал все, что знаю, чтобы понять это, но не могу. Я здесь, чтобы предоставить дополнительную информацию, спасибо за помощь!