firebase_messaging:^ 4.0.0 + 4无效

问题描述 投票:1回答:1

错误:-

Java.lang.NullPointerException:尝试在空对象引用上调用虚方法'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken()'

主build.gradle

依赖关系{classpath'com.android.tools.build:grad:3.3.1'classpath'com.google.gms:google-services:4.0.1'}

应用程序级build.gradle

依赖项{testImplementation'junit:junit:4.12'androidTestImplementation'com.android.support.test:runner:1.0.2'androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.2'implementation'com。 google.firebase:firebase-core:16.0.1'}适用插件:'com.google.gms.google-services'

AndroidManifest.xml中

<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:largeHeap="true" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
    <!-- This keeps the window background of the activity showing
    until Flutter renders its first frame. It can be removed if
    there is no splash screen (such as the default splash screen
    defined in @style/LaunchTheme). -->
    <meta-data android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:value="true" />

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>

</activity>
android firebase flutter firebase-cloud-messaging flutter-dependencies
1个回答
0
投票

我发现谷歌服务所需的版本位置插件和FCM插件的主要问题是不同的。

在应用程序级别最底层的build.gradle文件

 dependencies {
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.google.firebase:firebase-core:16.0.1' } 
apply plugin: 'com.google.gms.google-services' com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck
    = true
© www.soinside.com 2019 - 2024. All rights reserved.