繁体   English   中英

Flutter:java.lang.NoClassDefFoundError:解析失败:Lcom/google/firebase/iid/FirebaseInstanceId

[英]Flutter: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId

SDK:颤振

我们在我们的应用程序中使用 Flutter 和 Firebase 消息传递。 除此之外,我们还使用 plain_notification_token 来获取 Android 的 FCM 令牌和 iOS 的 APNS 令牌。 将 Gradle 升级到 4.2.2 时出现此错误。

问题

E/AndroidRuntime(27480):    at net.kikuchy.plain_notification_token.PlainNotificationTokenPlugin.onMethodCall(PlainNotificationTokenPlugin.java:47)
E/AndroidRuntime(27480):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/AndroidRuntime(27480):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/AndroidRuntime(27480):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/AndroidRuntime(27480):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime(27480):    at android.os.MessageQueue.next(MessageQueue.java:335)
E/AndroidRuntime(27480):    at android.os.Looper.loop(Looper.java:183)
E/AndroidRuntime(27480):    at android.app.ActivityThread.main(ActivityThread.java:8010)
E/AndroidRuntime(27480):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27480):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
E/AndroidRuntime(27480):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
E/AndroidRuntime(27480): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceId" on path: DexPathList[[zip file "/data/app/~~5gcFVfnQoOUOHN3V15pnZA==/money.bullet.internal-fy-pjwoLC9rHFRqMpeWWJw==/base.apk"],nativeLibraryDirectories=[/data/app/~~5gcFVfnQoOUOHN3V15pnZA==/money.bullet.internal-fy-pjwoLC9rHFRqMpeWWJw==/lib/arm64, /data/app/~~5gcFVfnQoOUOHN3V15pnZA==/money.bullet.internal-fy-pjwoLC9rHFRqMpeWWJw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
E/AndroidRuntime(27480):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
E/AndroidRuntime(27480):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(27480):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(27480):    ... 11 more
I/Process (27480): Sending signal. PID: 27480 SIG: 9
Lost connection to device.

安卓/app/build.gradle

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'androidx.core:core:1.6.0'
    implementation 'androidx.fragment:fragment:1.3.5'
    implementation "com.clevertap.android:clevertap-android-sdk:4.1.1"
    implementation 'com.google.android.play:core:1.10.0'
    implementation 'com.google.android.gms:play-services-basement:17.6.0'

    //MANDATORY for App Inbox
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.viewpager:viewpager:1.0.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.github.bumptech.glide:glide:4.11.0'

    //For CleverTap Android SDK v3.6.4 and above add the following -
    implementation 'com.android.installreferrer:installreferrer:2.2'

    //Optional ExoPlayer Libraries for Audio/Video Inbox Messages. Audio/Video messages will be dropped without these dependencies
    implementation 'com.google.android.exoplayer:exoplayer:2.14.1'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.14.1'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.14.1'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'

    // For bureau-sdk to get the advertising-id
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
//    implementation 'com.google.firebase:firebase-iid'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'

googleServices { disableVersionCheck = true }

这是 build.gradle 文件,在将 Gradle 版本从 3.x 更新到 4.2.2 后,Flutter 项目中开始出现问题。 我能够编译应用程序,但应用程序在运行时崩溃。

构建.gradle

buildscript {
    ext.kotlin_version = '1.5.20'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.8'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
        classpath 'com.google.firebase:perf-plugin:1.4.0'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
    configurations.all {
        resolutionStrategy {
            forcedModules = [
                    "com.google.android.gms:play-services-vision-common:19.0.2",
            ]
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

添加

 implementation 'com.google.firebase:firebase-iid'

到您的 Android/app/build.gradle ,这应该可以解决问题。

实施 'com.google.firebase:firebase-iid'

在 build.gradle 中添加这一行

为我工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM