Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception: java.lang.NoClassDefFoundError #648

Open
SzotsLevente opened this issue Jul 16, 2024 · 10 comments
Open

Fatal Exception: java.lang.NoClassDefFoundError #648

SzotsLevente opened this issue Jul 16, 2024 · 10 comments

Comments

@SzotsLevente
Copy link

SzotsLevente commented Jul 16, 2024

Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/messaging/RemoteMessage;
at com.clevertap.android.sdk.pushnotification.fcm.CTFirebaseMessagingReceiver.onReceive(CTFirebaseMessagingReceiver.java:110)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4637)
at android.app.ActivityThread.access$2900(ActivityThread.java:260)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2465)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

Recently implemented push notification for fcm and huawei as well getting the following error on some samsung s23, note 20 ultra 5g, motorola edge 30, oppo A79 5g and mostly on huawei phones like p30 pro, p30 lite, nova 5T, p20 pro, p20 lite, mate 20 pro, mate 10 pro.. list goes on

To Reproduce
what i've done is the following in the HmsMessagingService and in the FirebaseMessagingService as well:

CleverTapAPI.createNotificationChannel(applicationContext, channelId, getString(R.string.app_name), getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH, true)

remoteMessage.data.apply(on hms -> remoteMessage.dataOfMap.apply) {
try {
if (isNotEmpty()) {
val extras = Bundle()
for ((key, value) in this) {
extras.putString(key, value)
}
val info = CleverTapAPI.getNotificationInfo(extras)
Log.d(
TAG,
"onMessageReceived: $info ---- ${info.fromCleverTap}"
)
if (info.fromCleverTap) {
CleverTapAPI.createNotification(applicationContext, extras)
}
}
} catch (e: Exception) {
Log.e(TAG, "onMessageReceived: ${e.message}")
}
}

Crashlytics show that this issue happens mostly on android 10(like 90% of the cases)

ps i'm using these:
gmsImplementation 'com.clevertap.android:clevertap-android-sdk:6.2.1'
hmsImplementation 'com.clevertap.android:clevertap-hms-sdk:1.3.3'

hmsImplementation "com.huawei.hms:location:$huaweiLocationVersion"
hmsImplementation "com.huawei.hms:push:$huaweiPushVersion"

implementation platform("com.google.firebase:firebase-bom:$firebaseBom")
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-crashlytics'
gmsImplementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-storage'
@piyush-kukadiya
Copy link
Contributor

@SzotsLevente Seems like firebase dependency is not available at runtime. Can you share dependencies declared in gradle?

@SzotsLevente
Copy link
Author

SzotsLevente commented Jul 23, 2024

@piyush-kukadiya as you can see in the bottom of my post i've added all the dependancies that i've used in gradle, not sure if i've missed any, is there any mistake in my code? i've sent test notification for both type of devices from clevertap and received them, but this error is still happening on so many devices as crashlytics shows

gmsImplementation 'com.clevertap.android:clevertap-android-sdk:6.2.1'
hmsImplementation 'com.clevertap.android:clevertap-hms-sdk:1.3.3'

hmsImplementation "com.huawei.hms:location:$huaweiLocationVersion"
hmsImplementation "com.huawei.hms:push:$huaweiPushVersion"

implementation platform("com.google.firebase:firebase-bom:$firebaseBom")
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-crashlytics'
gmsImplementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-storage'

@piyush-kukadiya
Copy link
Contributor

@SzotsLevente Can you share small sample app reproducing this issue. It's mostly configuration issue because com/google/firebase/messaging/RemoteMessage is not available at run time. You an also try to validate this error by checking if com/google/firebase/messaging/RemoteMessage exists in your decompiled apk. One more case you need to check is Proguard. Proguard can rename class names in final release build.

@SzotsLevente
Copy link
Author

SzotsLevente commented Jul 23, 2024

@piyush-kukadiya the above mentioned code is simply put in a service that extends HmsMessageService and for gms FirebaseMessagingService, in both i check as it shows above that if it's from clevertap i use CleverTapAPI.createNotification(applicationContext, extras) if not i'm handling it as i should, the error occures mostly on huawei devices(with google services) i've checked proguard all firebase and hms related things are there with --keep, do you have a sample app where all should work so i can compare with it? fcm + hms + clevertap

i've the import for that for sure other way it would crash my other implementation that is not related with clevertap,

gmsImplementation 'com.google.firebase:firebase-messaging'

My class that extends FirebaseMessagingService has the import -> import com.google.firebase.messaging.RemoteMessage and it works just fine

HmsMessageService has the following import -> import com.huawei.hms.push.RemoteMessage

@piyush-kukadiya
Copy link
Contributor

@SzotsLevente I am testing out, will get back here with findings.

@piyush-kukadiya
Copy link
Contributor

@SzotsLevente we have tested this on Huawei P30. It's working fine from our end. Please raise internal support ticket with our support team via the Help Center.

@SzotsLevente
Copy link
Author

SzotsLevente commented Jul 26, 2024

@piyush-kukadiya already done that, have you tested out my code? can you link your sample project, would like to take look at it and compare, there must be some difference if it's working for you.

@piyush-kukadiya
Copy link
Contributor

@SzotsLevente I tested this in our internal app, but I am still sharing the new sample app here: https://github.com/pulsee/CleverTapHuawei

@piyush-kukadiya
Copy link
Contributor

@SzotsLevente Also, please note that CTFirebaseMessagingReceiver will only be invoked when the push notification is from Firebase. If the push notification is from HMS, CTFirebaseMessagingReceiver will not be triggered at all.

@SzotsLevente
Copy link
Author

SzotsLevente commented Jul 29, 2024

@piyush-kukadiya yeah i know that only phones that reacive from firebase will trigger that, that's why it's fishy, because my firebase implementation works properly, the only new thing that i've added was clevertap and those devices that i've mentioned use google play services so they receive notifications from firebase/CTFirebaseMessagingReceiver, that's why i don't understand why that error occurs.

the only thing is different now is that i've this verification added where i check if it's coming from clevertap or not
remoteMessage.data.apply(on hms -> remoteMessage.dataOfMap.apply) {
try {
if (isNotEmpty()) {
val extras = Bundle()
for ((key, value) in this) {
extras.putString(key, value)
}
val info = CleverTapAPI.getNotificationInfo(extras)
Log.d(
TAG,
"onMessageReceived:
{info.fromCleverTap}"
)
if (info.fromCleverTap) {
CleverTapAPI.createNotification(applicationContext, extras)
}else{
//same old firebase stuff goes here/or hms stuff
}
}
} catch (e: Exception) {
Log.e(TAG, "onMessageReceived: ${e.message}")
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants