RevenueCat / purchases-android

Android in-app purchases and subscriptions made easy.
https://www.revenuecat.com/
MIT License
235 stars 45 forks source link

RevenueCat paywall Caused by: java.lang.NoSuchMethodError: No direct method to getThemeColors #1703

Closed Mustafax06 closed 2 months ago

Mustafax06 commented 2 months ago

Describe the bug My deps:

How I call the paywall:

        @JvmStatic
        fun requestPaywall() {
            // This function is called from Unity to request the paywall.
            instance.runOnUiThread {
                val paywallView = instance.findViewById<ComposeView>(R.id.paywallComposeView)
                paywallView.setContent { 
                    MaterialTheme {
                        PaywallScreen()
                    }
                }
            }
        }

PaywallView Class:

@OptIn(ExperimentalPreviewRevenueCatUIPurchasesAPI::class)
@Composable
fun PaywallScreen() {
    PaywallDialog(PaywallDialogOptions.Builder().setRequiredEntitlementIdentifier("12291").setListener(object : PaywallListener {
        override fun onPurchaseCompleted(customerInfo: CustomerInfo, storeTransaction: StoreTransaction) {}
        override fun onRestoreCompleted(customerInfo: CustomerInfo) {}
    }).build())
}

Application Class


class MainApplication : Application() {
    private val revenueCatId = "my_id"

    override fun onCreate() {
        super.onCreate()

        initBranch()
        initRevenueCat()
    }

    private fun initBranch() {
        Branch.registerPlugin("Unity", "1.0.0")
        Branch.disableInstantDeepLinking(true)
        Branch.getAutoInstance(this.applicationContext)
    }

    private fun initRevenueCat() {
        Purchases.logLevel = if (BuildConfig.DEBUG) LogLevel.DEBUG else LogLevel.ERROR
        Purchases.configure(PurchasesConfiguration.Builder(context = this, apiKey = revenueCatId).build())
    }
}

Proguard file: -keep class com.revenuecat.purchases.* { ; }

Gradle Version: 7.4

I run a Unity app on a native Andorid project. So my app uses both RevenueCat-Hybrid and the Android one (Unity as a library). I followed the documentation but maybe the problem is using both SDKs. I don't want to remove the Unity lib since it's used very ofent in the app. I need to make them work side by side. I don't think the logs will help to reproduce the issue but it still might help. There's nothing on the forum and other sites about the issue: PaywallColor.

  1. Environment
    1. Platform: Android
    2. SDK version: 7.10.1 - UI 7.1.0 - Hybrid 10.6.1
    3. OS version: 13
    4. Android Studio version: Android Studio Jellyfish | 2023.3.1
    5. How widespread is the issue. Percentage of devices affected: Happens on my local two local devices; Samsung S20 FE and Xiaomi Redmi Note 12 Pro
  2. Debug logs that reproduce the issue FATAL EXCEPTION: main Process: com.mycom.myApp:Unity, PID: 1652 java.lang.NoSuchMethodError: No direct method <init>(Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;Lcom/revenuecat/purchases/paywalls/PaywallColor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V in class Lcom/revenuecat/purchases/paywalls/PaywallData$Configuration$Colors; or its super classes (declaration of 'com.revenuecat.purchases.paywalls.PaywallData$Configuration$Colors' appears in /data/app/~~ZMp79N2Em8ZzR_ZKHZdJZA==/com.mycom.myApp-3RMBFjmgPXNfv6KEVjDlPA==/base.apk!classes4.dex) at com.revenuecat.purchases.ui.revenuecatui.extensions.PaywallDataExtensionsKt.getThemeColors(PaywallDataExtensions.kt:111) at com.revenuecat.purchases.ui.revenuecatui.extensions.PaywallDataExtensionsKt.defaultColors(PaywallDataExtensions.kt:101) at com.revenuecat.purchases.ui.revenuecatui.extensions.PaywallDataExtensionsKt.createDefaultForIdentifiers(PaywallDataExtensions.kt:53) at com.revenuecat.purchases.ui.revenuecatui.extensions.PaywallDataExtensionsKt.createDefault(PaywallDataExtensions.kt:33) at com.revenuecat.purchases.ui.revenuecatui.LoadingPaywallKt.LoadingPaywall(LoadingPaywall.kt:50) at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$1$1.invoke(InternalPaywall.kt:58) at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$1$1.invoke(InternalPaywall.kt:57) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:818) at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibilityImpl(AnimatedVisibility.kt:741) at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:135) at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$1.invoke(InternalPaywall.kt:53) at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$1.invoke(InternalPaywall.kt:47) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at com.revenuecat.purchases.ui.revenuecatui.fonts.PaywallThemeKt.PaywallTheme(PaywallTheme.kt:15) at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.InternalPaywall(InternalPaywall.kt:47) at com.revenuecat.purchases.ui.revenuecatui.PaywallKt.Paywall(Paywall.kt:12) at com.revenuecat.purchases.ui.revenuecatui.PaywallDialogKt$DialogScaffold$1.invoke(PaywallDialog.kt:79) at com.revenuecat.purchases.ui.revenuecatui.PaywallDialogKt$DialogScaffold$1.invoke(PaywallDialog.kt:73) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.material3.ScaffoldKt$ScaffoldLayoutWithMeasureFix$1$1$bodyContentPlaceables$1.invoke(Scaffold.kt:303) at androidx.compose.material3.ScaffoldKt$ScaffoldLayoutWithMeasureFix$1$1$bodyContentPlaceables$1.invoke(Scaffold.kt:285) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$3$1$1.invoke(SubcomposeLayout.kt:991) com.mycom.myApp E at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$3$1$1.invoke(SubcomposeLayout.kt:477) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:90) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3302) at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3235) at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:725) at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1071) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3599) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3599) at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:633) at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:619) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:500) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:472) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:463) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:447) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:872) at androidx.compose.material3.ScaffoldKt$ScaffoldLayoutWithMeasureFix$1$1.invoke-0kLqBqw(Scaffold.kt:285) at androidx.compose.material3.ScaffoldKt$ScaffoldLayoutWithMeasureFix$1$1.invoke(Scaffold.kt:179) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:709) at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:126) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:252) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:251) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1617) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:620) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:596) at androidx.compose.foundation.layout.BoxMeasurePolicy.measure-3p2s80s(Box.kt:122) at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:126) at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116) at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116) at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:699) 2024-05-20 11:39:43.126 1652-1652 AndroidRuntime com.mycom.myApp E at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116) at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:699) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:252) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:251) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1617) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:620) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:596) at androidx.compose.ui.window.AndroidDialog_androidKt$DialogLayout$1.measure-3p2s80s(AndroidDialog.android.kt:458) at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:126) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:252) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:251) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1617) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:620) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:596) at androidx.compose.ui.layout.RootMeasurePolicy.measure-3p2s80s(RootMeasurePolicy.kt:38) at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:126) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:252) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:251) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113) 2024-05-20 11:39:43.127 1652-1652 AndroidRuntime com.mycom.myApp E at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1617) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:620) at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1145) at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:354) at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureOnly(MeasureAndLayoutDelegate.kt:562) at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureOnly(MeasureAndLayoutDelegate.kt:407) at androidx.compose.ui.platform.AndroidComposeView.onMeasure(AndroidComposeView.android.kt:1058) at android.view.View.measure(View.java:27731) at androidx.compose.ui.platform.AbstractComposeView.internalOnMeasure$ui_release(ComposeView.android.kt:302) at androidx.compose.ui.window.DialogLayout.internalOnMeasure$ui_release(AndroidDialog.android.kt:242) at androidx.compose.ui.platform.AbstractComposeView.onMeasure(ComposeView.android.kt:289) at android.view.View.measure(View.java:27731) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:27731) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:27731) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1379) at android.view.View.measure(View.java:27731) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4841) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:3397) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3732) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3116) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10885) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1301) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309) at android.view.Choreographer.doCallbacks(Choreographer.java:923) at android.view.Choreographer.doFrame(Choreographer.java:852) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8762) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
  3. Steps to reproduce, with a description of expected vs. actual behavior Expected behavior is showing the paywall
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Additional context Add any other context about the problem here.

RCGitBot commented 2 months ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

Mustafax06 commented 2 months ago

I fixed it by adding the below to my app's build.gradle file

configurations.configureEach {
    resolutionStrategy {
        force 'com.revenuecat.purchases:purchases:7.1.0'
        force 'com.revenuecat.purchases:purchases-ui:7.1.0'
    }
}

My Unity library was overriding the lib. This is an extremely rare case but still might be helpful to someone

github-actions[bot] commented 1 month ago

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.