Invalid sender Id while getting device token

2019-08-17 19:28发布

I am doing Firebase cloud messaging setup in my Android App. I am not doing it first time.I have done it many times. But this time I am getting a strange error "Invalid Sender ID" while trying to get device token.I have never used any Sender Id in My Project ever except Project number which is by default present in google-services.json file.Please help me out of this

.I am using this method to generate token.I have added google-services.json file in my Project

 FirebaseInstanceId.getInstance().getInstanceId()
            .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
                @Override
                public void onComplete(@NonNull Task<InstanceIdResult> task) {
                    if (!task.isSuccessful()) {
                        Toast.makeText(WelcomeActivity.this,task.getException().getMessage(),Toast.LENGTH_LONG).show();
                        Log.w("getInstanceId failed", task.getException());
                        return;
                    }

                    // Get new Instance ID token
                    String token = task.getResult().getToken();
                    Log.v("sssskkkk",token);

                }
            });

I am using following dependencies in my Project

 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
api fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-messaging:17.3.4'
testImplementation('com.android.support.test.espresso:espresso-core:2.2.2')

implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'org.immutables:gson:2.4.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'

implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
implementation 'com.borjabravo:readmoretextview:2.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.github.mabbas007:TagsEditText:1.0.5'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'


implementation 'com.android.support:support-core-utils:28.0.0'

implementation 'com.karumi:dexter:4.2.0'

I am pretty sure that I am not missing anything in implementation of Firebase cloud messaging.Also when I am using same google-services.json in different project with same package name then all working fine.

1条回答
不美不萌又怎样
2楼-- · 2019-08-17 20:15

Yeah finally I solved it after spending around 30 hours on it.That code was done by previous developer and I found that there were two google-services.json files, one in app folder and another in debug folder so Sender ID's were mismatching in it.So I would like to suggest all those who are getting this error:-

  1. Should check that you have copied your file in correct folder that is app.
  2. Should check the file is correct and matches with latest downloaded google-services.json file in FCM
  3. Should check that is there any duplicate file of google-services.json present in your project?
查看更多
登录 后发表回答