CleverTap / clevertap-android-sdk

CleverTap Android SDK
MIT License
80 stars 74 forks source link

App crashes when trying to open clevertap inbox w/ v 7.0.1 #671

Open manumuuv opened 1 month ago

manumuuv commented 1 month ago

Describe the bug I've upgraded to v7.0.1, which doesn't have Utils.haveVideoPlayerSupport anymore, and the app crashes when I try to open the clevertap inbox.

To Reproduce Steps to reproduce the behavior:

  1. having a user that already have a message in its clevertap inbox
  2. Open the Clevertap inbox
  3. See crash

Expected behavior The clevertap inbox should open as it does when I use older clevertapSdk version with Utils.haveVideoPlayerSupport set to false

Screenshots/Logs Error stack trace:

FATAL EXCEPTION: main
                 Process: com.my.app, PID: 6564
                 java.lang.AbstractMethodError: abstract method "void androidx.media3.common.Player$Listener.onSurfaceSizeChanged(int, int)"
                    at androidx.media3.exoplayer.ExoPlayerImpl.lambda$maybeNotifySurfaceSizeChanged$27(ExoPlayerImpl.java:2747)
                    at androidx.media3.exoplayer.ExoPlayerImpl$$ExternalSyntheticLambda20.invoke(D8$$SyntheticClass:0)
                    at androidx.media3.common.util.ListenerSet$ListenerHolder.invoke(ListenerSet.java:339)
                    at androidx.media3.common.util.ListenerSet.lambda$queueEvent$0(ListenerSet.java:223)
                    at androidx.media3.common.util.ListenerSet$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
                    at androidx.media3.common.util.ListenerSet.flushEvents(ListenerSet.java:245)
                    at androidx.media3.common.util.ListenerSet.sendEvent(ListenerSet.java:260)
                    at androidx.media3.exoplayer.ExoPlayerImpl.maybeNotifySurfaceSizeChanged(ExoPlayerImpl.java:2746)
                    at androidx.media3.exoplayer.ExoPlayerImpl.setVideoSurfaceHolder(ExoPlayerImpl.java:1376)
                    at androidx.media3.exoplayer.ExoPlayerImpl.setVideoSurfaceView(ExoPlayerImpl.java:1407)
                    at androidx.media3.ui.PlayerView.setPlayer(PlayerView.java:597)
                    at com.clevertap.android.sdk.video.inbox.Media3Handle.initPlayerView(Media3Handle.kt:113)
                    at com.clevertap.android.sdk.customviews.MediaPlayerRecyclerView.initialize(MediaPlayerRecyclerView.kt:193)
                    at com.clevertap.android.sdk.customviews.MediaPlayerRecyclerView.<init>(MediaPlayerRecyclerView.kt:61)
                    at com.clevertap.android.sdk.inbox.CTInboxListViewFragment.onCreateView(CTInboxListViewFragment.java:132)

Environment (please complete the following information):

Additional context I made sure I have the same media3 version (1.1.1) It only happens in release builds. I have this set as compile options

compileOptions {
            coreLibraryDesugaringEnabled true
            sourceCompatibility JavaVersion.VERSION_17
            targetCompatibility JavaVersion.VERSION_17
        }

        kotlinOptions {
            jvmTarget = '17'
        }

If it's possible to add a way to disable Video player support, as there were in previous versions haveVideoPlayerSupport) it would be great but if there is a way to fix it supporting Video player it would be even better.

Let me know if you need more info.

Thank you

CTLalit commented 1 month ago

I think obfuscation is causing the issue since you have mentioned this issue happens only in the release builds. You can try this configuration in proguard and check if the issue is resolved? -keep com.clevertap.android.sdk.**

Some of the gradle versions have an issue reported where similar thing is seen https://issuetracker.google.com/issues/133457361 -> please make sure you are not on these versions/use the workarounds if this is the issue.

You can check with these 2 things and see if things work for you?

manumuuv commented 1 month ago

Thanks for the quick reply.

I do have -keep class com.clevertap.android.sdk.** and I don't think it's an obfuscation problem, as the issue is still there when I set minifyEnabled false

Upgrading gradle version doesn't help either, I have gradle-8.4, and upgrading to gradle-8.6 doesn't fix the issue. The workarounds don't work as they are deprecated in new versions of gradle

PLease let me know if you need more information from my side

CTLalit commented 1 month ago

I found this thread in list of issues on media3 repo -> https://github.com/google/ExoPlayer/issues/6801

Pointers from the thread : Did you try to invalidate caches and restart, some users have reported this might be android studio/gradle caching issue Did you try to include the dependency via an .aar file?

On a side note can you provide full build.gradle and possibly a min implementation to reproduce this issue, it seems to be stemming from media3 and packaging android bundle side and clevertap is merely the invocation site.

Kindly try out these things and help me with more information about a minimum viable app to reproduce this issue.

manumuuv commented 1 month ago

As mentioned in the ExoPLayer issue you share the problem is happening if generating signed builds.

gradle.properties:


android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=true
android.jetifier.ignorelist=bcprov-jdk15on
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4608m

build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.github.ben-manes.versions'
apply from: 'dependency_upgrade_plugin.gradle'

repositories {
    maven {
        url "https://jitpack.io"
    }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
    mavenCentral()
}

android {
    namespace 'com.yourtrainer.android'
    signingConfigs {
        debug {
            storeFile file("./debug.keystore")
        }
        release {
            //key store file...
        }
    }
    compileSdkVersion 34
    buildToolsVersion '34.0.0'
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 34
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true

            sourceCompatibility JavaVersion.VERSION_17
            targetCompatibility JavaVersion.VERSION_17
        }

        kotlinOptions {
            jvmTarget = '17'
        }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled false
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    viewBinding {
        enabled = true
    }
    buildFeatures {
        compose = true
    }

    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.11"
    }

    flavorDimensions "product", "env"
    productFlavors {
        _app {
            dimension "product"
            versionCode buildVersion
            versionName buildName
//            applicationId "..."
//            manifestPlaceholders.appName = "..."
//            buildConfigFields
//
        }
        develop {
            dimension "env"
            applicationIdSuffix ".dev"
            manifestPlaceholders.appNameSuffix = " Dev"
            manifestPlaceholders.branchTestMode = "true"
        }
        production {
            dimension "env"
            manifestPlaceholders.branchTestMode = "false"
        }
    }
    lint {
        abortOnError true
        baseline file('lint-baseline.xml')
        checkAllWarnings true
        checkGeneratedSources true
        disable 'GradleDependency', 'NewerVersionAvailable', 'NewApi', 'SyntheticAccessor', "JvmStaticProvidesInObjectDetector", "FieldSiteTargetOnQualifierAnnotation", "ModuleCompanionObjects", "ModuleCompanionObjectsNotInModuleParent"
        warningsAsErrors true
    }
}

configurations {
    ktlint
}

tasks.register('ktlint', JavaExec) {
    description = "Check Kotlin code style."
    classpath = configurations.ktlint
    mainClass.set("com.pinterest.ktlint.Main")
    args "src/**/*.kt"
}
check.dependsOn ktlint

tasks.register('ktlintFormat', JavaExec) {
    description = "Fix Kotlin code style deviations."
    classpath = configurations.ktlint
    mainClass.set("com.pinterest.ktlint.Main")
    args "-F", "src/**/*.kt"
    jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED"
}

tasks.register('installGitHook', Copy) {
    from new File(rootProject.rootDir, 'scripts/pre-commit') into { new File(rootProject.rootDir, '.git/hooks') }
    fileMode 0777
    from new File(rootProject.rootDir, 'scripts/pre-push') into { new File(rootProject.rootDir, '.git/hooks') }
    fileMode 0777
}

tasks.getByPath('preBuild').dependsOn installGitHook

dependencies {

    coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4"

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23"

    implementation "androidx.media3:media3-session:1.1.1"
    implementation "androidx.media3:media3-exoplayer:1.1.1"
    implementation "androidx.media3:media3-ui:1.1.1"
    implementation "androidx.media3:media3-common:1.1.1"
    implementation "androidx.media3:media3-exoplayer-hls:1.1.1"

    implementation "com.clevertap.android:clevertap-segment-android:1.6.0"
    implementation "com.clevertap.android:clevertap-android-sdk:7.0.1"

    ktlint("com.pinterest:ktlint:$versions.ktlint") {
        attributes {
            attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
        }
    }
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
manumuuv commented 1 month ago

Trying to generate minimum implementation to reproduce the crash, I found out the issue is solved if I change the minSdk from minSdkVersion 21 to minSdkVersion 24. I don't know why, but I'll keep investigating