Closed iyasilias closed 3 years ago
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.
Please see the Contributing Guide for how to create a Code Reproduction.
Thanks! Ionitron š
I'll try to reply asap. I've got some errands to do first.
I wasn't able to reproduce the error. Maybe it is the result of the complexity of my app. Anyhow, I was able to fix the problem. So I think I would like to share it here.
And yes, it has to do with the deprecation of FirebaseInstanceId.
In PushNotifactions.java from line 84: Change this
public void register(PluginCall call) {
FirebaseMessaging.getInstance().setAutoInitEnabled(true);
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
sendToken(instanceIdResult.getToken());
}
});
FirebaseInstanceId.getInstance().getInstanceId().addOnFailureListener(new OnFailureListener() {
public void onFailure(Exception e) {
sendError(e.getLocalizedMessage());
}
});
call.success();
}
to this
public void register(PluginCall call) {
FirebaseMessaging.getInstance().setAutoInitEnabled(true);
FirebaseMessaging.getInstance().getToken().addOnSuccessListener(getActivity(), new OnSuccessListener<String>() {
@Override
public void onSuccess(String s) {
sendToken(s);
}
});
FirebaseMessaging.getInstance().getToken().addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
sendError(e.getLocalizedMessage());
}
});
call.success();
}
This issue shouldn't be closed as it is still present in all versions of Capacitor. You found a workaround but the issue still persists. Also the workaround didnt work for me on Capacitor v2.4.7.
does your issue same as mine? if so, i think the workaround should fix the problem.. how about you open a new issue then paste the error message, may be yours a bit different?
@iyasilias I think its because I was using PushNotifications.requestPermission() according to older documentation. I found someone was using requestPermissions() with an "s" and it seemed to work now. I will get back to you when I have at this again.
I can confirm that the documentation for Capacitor 2 is wrong and posts broken code. you need that extra "s" on requestPermission
.
I have had this error when moving over to this plugin. The issue exists when building and running on an emulator using API 30 but not when running on API 29.
Check this out: https://stackoverflow.com/questions/68320549/flutter-java-lang-noclassdeffounderror-failed-resolution-of-lcom-google-fireb
It says you just have to add
implementation 'com.google.firebase:firebase-iid'
to the gradle file of your app.
It worked for me :+1:
@patryk-eco your suggestion worked for me
I wasn't able to reproduce the error. Maybe it is the result of the complexity of my app. Anyhow, I was able to fix the problem. So I think I would like to share it here.
And yes, it has to do with the deprecation of FirebaseInstanceId.
In PushNotifactions.java from line 84: Change this
public void register(PluginCall call) { FirebaseMessaging.getInstance().setAutoInitEnabled(true); FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() { @Override public void onSuccess(InstanceIdResult instanceIdResult) { sendToken(instanceIdResult.getToken()); } }); FirebaseInstanceId.getInstance().getInstanceId().addOnFailureListener(new OnFailureListener() { public void onFailure(Exception e) { sendError(e.getLocalizedMessage()); } }); call.success(); }
to this
public void register(PluginCall call) { FirebaseMessaging.getInstance().setAutoInitEnabled(true); FirebaseMessaging.getInstance().getToken().addOnSuccessListener(getActivity(), new OnSuccessListener<String>() { @Override public void onSuccess(String s) { sendToken(s); } }); FirebaseMessaging.getInstance().getToken().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { sendError(e.getLocalizedMessage()); } }); call.success(); }
this worked for me
Check this out: https://stackoverflow.com/questions/68320549/flutter-java-lang-noclassdeffounderror-failed-resolution-of-lcom-google-fireb
It says you just have to add
implementation 'com.google.firebase:firebase-iid'
to the gradle file of your app.
It worked for me š
This worked for me
Check this out: https://stackoverflow.com/questions/68320549/flutter-java-lang-noclassdeffounderror-failed-resolution-of-lcom-google-fireb
It says you just have to add
implementation 'com.google.firebase:firebase-iid'
to the gradle file of your app.
It worked for me š
this worked for me š
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Bug Report
Didn't find class "com.google.firebase.iid.FirebaseInstanceId" when using Push Notification on Android (publish success, but the app will crash when entering page with Push Notification code. When debugging, the error above appears).
Capacitor Version
Platform(s)
Android
Current Behavior
Problem with Firebase Instant ID
Expected Behavior
Should use the new one since FirebaseInstanceId is deprecated.
Code Reproduction
Other Technical Details
npm --version
output: 6.12.1node --version
output: v12.13.1pod --version
output (iOS issues only): 1.10.1Additional Context
Actually similar bug also appears on ios, but I fix with the guide from here. https://medium.com/nerd-for-tech/how-to-solve-capacitor-error-no-such-module-firebaseinstanceid-9c142933b589
Upon inspecting the debug message, I came across this code
Now I'm pretty sure I just have to change FirebaseInstanceId.getInstance().getInstanceId() with new implementation, but I do not know how.. I've tried
FirebaseInstallations.getInstance().getId()
but seems to have problem with addOnSuccessListener.I really can't afford Capacitor 3 at this time. Please help.
TQ.