apptentive / apptentive-android

Apptentive Android SDK
http://www.apptentive.com
BSD 3-Clause "New" or "Revised" License
65 stars 64 forks source link

Crash with some older versions of com.google.android.play:core dependency #231

Closed kite247 closed 2 years ago

kite247 commented 2 years ago

Hi,

is anyone else running into crash issues when not using the latest play:core library? The crash happens when the user clicks "Yes" on the love dialog.

Here is the stack trace:

Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/play/core/review/ReviewManagerFactory;
       at com.apptentive.android.sdk.external.GooglePlayReviewManager.<init>(GooglePlayReviewManager.java:25)
       at com.apptentive.android.sdk.external.DefaultInAppReviewManagerFactory.createReviewManager(DefaultInAppReviewManagerFactory.java:37)
       at com.apptentive.android.sdk.module.engagement.InAppRatingDialogInteractionLauncher.launch(InAppRatingDialogInteractionLauncher.java:46)
       at com.apptentive.android.sdk.module.engagement.InAppRatingDialogInteractionLauncher.launch(InAppRatingDialogInteractionLauncher.java:21)
       at com.apptentive.android.sdk.module.engagement.EngagementModule.launchInteraction(EngagementModule.java:135)
       at com.apptentive.android.sdk.module.engagement.EngagementModule$1.execute(EngagementModule.java:122)
       at com.apptentive.android.sdk.util.threading.DispatchTask.run(DispatchTask.java:39)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8595)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Here are some build.gradle configurations that I tested:

build.gradle (will crash after pressing 'yes' on love dialog popup):

installedImplementation 'com.apptentive:apptentive-android:5.7.1'
implementation "com.google.android.play:core:1.7.2"

build.gradle (no crash):

installedImplementation 'com.apptentive:apptentive-android:5.7.1'
implementation "com.google.android.play:core:1.10.2"

I'm assuming Apptentive SDK 5.7.1 requires play:core version 1.10.2 to work properly or is it also supposed to work with older versions like 1.7.2?

If it requires play:core 1.10.2, is this documented somewhere? I couldn't find any information like this in the release notes or Apptentive documentation.

I'm trying to avoid similar issues in the future. Is there documentation somewhere that points out which dependency library versions Apptentive SDK requires?

CaseyApptentive commented 2 years ago

Hi @kite247. So sorry that you're seeing a crash! This is the first report of it that we've heard.

We'll dig in but may reach out with more questions.

ChaseApptentive commented 2 years ago

Hi @kite247!

The issue here is around the Rating interaction. It looks like you have that coupled to show when the user selects 'yes' in their Love Dialog Interaction.

When we try to trigger the In-App Review, Google attempts to find their ReviewManagerFactory, and in order for that to occur, they require at least version 1.8.0 of the Play Core library, or else a NoClassDefFoundError occurs.

Within our SDK, we do have an implementation of the Play Core Library that supports Google In-App Review, however, the host app's version is preferred if they have also implemented the same library, which is what is happening here.

So in a nutshell, if you wish to use a legacy version of the Play Core library AND want to use our Ratings Interaction to see the Google In-App Review, you'll have to implement at least version 1.8.0 of the Play Core library.

If you need to use an older version, you'll have to consider using a Rating Provider, which should bypass this error. Though it will not allow you to use the same Google In-App Review, which may result in less effective app reviews.

We have updated our documentation under the Love Dialog & Rating Dialog subsection.

Thank you!

Closing the issue.

kite247 commented 2 years ago

Hi Chase,

thanks for the quick response and for updating the documentation to make it clear which play core version is required.

For future Apptentive SDK version updates that require updates on any dependency libraries, it would be super helpful to add this information to the release notes.

This way developers can make sure that they also update the dependency libraries to the required version whenever they update the Apptentive SDK.

ChaseApptentive commented 2 years ago

@kite247

We will do that from now on 😄

Thank you.