gpt4 book ai didi

android - Flutter firebase_messaging android 应用程序在 .getToken() 调用时崩溃

转载 作者:行者123 更新时间:2023-12-04 23:52:01 24 4
gpt4 key购买 nike

我正在尝试集成 firebase_messaging与我的 flutter 应用程序一起打包。通常它适用于我正在使用的代码(版本 7.0.3)(见下文),但由于发布了空安全版本,我的代码不再工作。我想知道是否有人可以帮助我找出我做错了什么?
错误导致代码

try {
fcmToken = await _firebaseMessaging.getToken();
} catch (error) {
print(error);
}
错误输出
E/AndroidRuntime( 8942): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/Metadata;
E/AndroidRuntime( 8942): at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin.lambda$getToken$1$FlutterFirebaseMessagingPlugin(FlutterFirebaseMessagingPlugin.java:165)
E/AndroidRuntime( 8942): at io.flutter.plugins.firebase.messaging.-$$Lambda$FlutterFirebaseMessagingPlugin$p8YQXDuFBNIxl8PFaPCQJtYc3sw.call(Unknown Source:4)
E/AndroidRuntime( 8942): at com.google.android.gms.tasks.zzv.run(Unknown Source:2)
E/AndroidRuntime( 8942): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 8942): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 8942): at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime( 8942): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.Metadata" on path: DexPathList[[zip file "/data/app/~~uCa7QFzhvu5i_TZpnqat0w==/com.example.****-1cbY-LKuCoOsfZybV-Gq6g==/base.apk"],nativeLibraryDirectories=[/data/app/~~uCa7QFzhvu5i_TZpnqat0w==/com.example.****-1cbY-LKuCoOsfZybV-Gq6g==/lib/x86, /data/app/~~uCa7QFzhvu5i_TZpnqat0w==/com.example.****-1cbY-LKuCoOsfZybV-Gq6g==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
E/AndroidRuntime( 8942): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
E/AndroidRuntime( 8942): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime( 8942): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime( 8942): ... 6 more
app -> src -> main -> kotlin -> Application.kt
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry

import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin

class Application() : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
override fun registerWith(registry: PluginRegistry?) {
val key: String? = FlutterFirebaseMessagingPlugin::class.java.canonicalName
if (!registry?.hasPlugin(key)!!) {
FlutterFirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin"));
}
}
}
app -> src -> main -> kotlin -> MainActivity.kt
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}

最佳答案

对我来说,它通过从降级来工作com.google.firebase:firebase-bom:28.0.1com.google.firebase:firebase-bom:27.0.0提示:这是这些版本的临时解决方案:firebase_messaging: ^9.1.4firebase_core: ^1.1.1

关于android - Flutter firebase_messaging android 应用程序在 .getToken() 调用时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67539602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com