CleverTap / clevertap-android-sdk

CleverTap Android SDK
MIT License
80 stars 74 forks source link

Fatal Exception: java.lang.RuntimeException Unable to create service com.clevertap.android.sdk.pushnotification.amp.CTBackgroundJobService: java.lang.ClassNotFoundException #576

Closed aaditya-doshi-hztl closed 7 months ago

aaditya-doshi-hztl commented 8 months ago

Using the 6.1.0 version for SDK and upon releasing the app to prod started getting this crash event in Firebase Crashlytics heavily. Any probable cause as to why it would happen ? Would be helpful if you can let me know the same and any solution to overcome the same. TIA

Stack trace from Crashlytics Fatal Exception: java.lang.RuntimeException Unable to create service com.clevertap.android.sdk.pushnotification.amp.CTBackgroundJobService: java.lang.ClassNotFoundException: Didn't find class "com.clevertap.android.sdk.pushnotification.amp.CTBackgroundJobService" on path: DexPathList[[zip file "/data/app/~~nxBt_oG34Qurxx3T2023kg==/com.enbd.android-4SzoOZ7yindg5qvrhANC2A==/base.apk", zip file

Anush-Shand commented 8 months ago

This crash is due to the pushamplification feature edge case - where the user updates the app (clevertap-version v6.0.0 or below to v6.1.1) but doesn't launch the app within the pingFrequency time (4 hours by default)

This crash is once per user.

This crash is in the background (app functionality is not affected but user will see an alert that the app stopped)

Workaround until the fix is released is to disable the service by adding this to their AndroidManifest.xml

  <service
      android:name="com.clevertap.android.sdk.pushnotification.amp.CTBackgroundJobService"
      android:exported="false"
      android:enabled="false"
      tools:ignore="MissingClass"/>

@aaditya-doshi-hztl

aaditya-doshi-hztl commented 8 months ago

@Anush-Shand Hey man, thanks for the prompt response. This helps, apart from doing this, would upgrading the SDK to latest would be a good idea ? and in the process of doing so would there be any special changes required to be done on the proguard rules or should that be taken care off itself by the SDK ? And also adding this in manifest would stop throwing the crash in crashlytics ?

Anush-Shand commented 8 months ago

@aaditya-doshi-hztl There was a critical bug identified in 6.1.0 and hence we recommend updating to v6.1.1. Also make sure to add the above mentioned entry in the AndroidManifest file. Other than this no other specific change is required. Once the fix is deployed it will be great if you can confirm that all the crashes related to the above mentioned Exception go away

aaditya-doshi-hztl commented 8 months ago

@Anush-Shand Noted ! If possible, please keep this bug open until I post an update for the behavior after SDK update.

Lakshyasukhralia commented 8 months ago

@Anush-Shand Any update about the release date for the updated SDK with the necessary fixes? Critical issues were identified in version 6.0.0, prompting an urgent update to address a token generation-related problem that has impacted many users, leading to missed Push Notification deliveries for our app.

Anush-Shand commented 8 months ago

@Lakshyasukhralia Could you elaborate on the critical issues in clevertap-android-sdk v6.0.0? If it's unrelated to the above mentioned issue, please open a new issue for ease of tracking. A workaround has been provided for the above mentioned issue regarding ClassNotFoundException.

raghavendra-uno commented 8 months ago

Hi @Anush-Shand We have updated the app to 6.1.1, but not added the manifest changes you asked for

<service android:name="com.clevertap.android.sdk.pushnotification.amp.CTBackgroundJobService" android:exported="false" android:enabled="false" tools:ignore="MissingClass"/>

still there is spike in Firebase. Should I add the above code in manifest. Adding this is showing a error in manifest of Unresolved class 'CTBackgroundJobService' is that fine?

Anush-Shand commented 8 months ago

@raghavendra-uno Yess, the manifest entry needs to be added to prevent the above mentioned crashes. Unresolved class shoudn't be an issue as this class in not used in the latest sdk

Anush-Shand commented 7 months ago

This issue has been fixed in clevertap-android-sdk v6.2.0