Firebase InstanceId: binding to the service failed: Kotlin

后端 未结 5 974
谎友^
谎友^ 2021-01-11 13:43

App successfully lanches but get this error message in debugging. FirebaseInstanceId: binding to the service failed

App Build Gradle:

android {
compi         


        
相关标签:
5条回答
  • 2021-01-11 13:56

    Add service tag inside application tag

    <application>
    
    ....
    
       <activity
    
             ....
    
       </activity>
    
       <service
           android:name=".MyFirebaseMessagingService"
           android:exported="false">
           <intent-filter>
               <action android:name="com.google.firebase.MESSAGING_EVENT" />
           </intent-filter>
        </service>
    
    </application>
    

    Then add a new kotlin file - MyFirebaseMessagingService.kt

    import com.google.firebase.messaging.FirebaseMessagingService;
    
    public class MyFirebaseMessagingService extends FirebaseMessagingService {
    
        @Override
        public void onNewToken(String s) {
            super.onNewToken(s);
            System.out.println("NEW_TOKEN :::::::::::::::::::::::::: "+s);
        }
    
    }
    

    Uninstall the App manually and reinstall. This will work.

    0 讨论(0)
  • 2021-01-11 13:58

    I downloaded the newest version of google-service.json (can be done via Firebase Settings). In my case there was a new entry added to oauth_client. After syncing with the file system and rebuilding my app the warning does not seem to appear anymore.

    EDIT 20-02-2020: After testing this a bit more it unfortunately doesn't seem to help in the end. In my case the error message only for sure occur when starting the app the first time after an uninstall of the app - in most other cases it does not happen.

    0 讨论(0)
  • 2021-01-11 13:58

    Please try to use an actual device. Per my observation, you'll get this kind of error when you use an emulator even though you've already downloaded all the required libraries related to Google Services. I was also able to see other errors from FirebaseInstanceId.

    0 讨论(0)
  • 2021-01-11 14:06

    I have added

    <uses-permission android:name="android.permission.INTERNET"/>
    

    In my manifest file and got rid of Firebase InstanceId: binding to the service failed. Hope it will help.

    0 讨论(0)
  • 2021-01-11 14:19

    In my case, login to Google Play on emulator (API: R) is fixed the problem. I think it's about Play Services.

    0 讨论(0)
提交回复
热议问题