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

Paywalls not working at all on Android platform #1111

Closed
11 tasks done
arabnology opened this issue Jul 4, 2024 · 7 comments
Closed
11 tasks done

Paywalls not working at all on Android platform #1111

arabnology opened this issue Jul 4, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@arabnology
Copy link

arabnology commented Jul 4, 2024

‼️ Required data ‼️

Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.

There are a lot of things that can contribute to things not working. Having a very basic understanding of your environment will help us understand your issue faster!

Environment

  • Output of flutter doctor
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-x64, locale
    en-SA)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.91.0)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPad. Ensure the device is
      unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)
[✓] Network resources
• No issues found!
  • Version of purchases-flutter
purchases_flutter: ^6.30.0
purchases_ui_flutter: ^6.30.0
  • Testing device version e.g.: iOS 15.5, Android API 30, etc.
    Android API 34
  • How often the issue occurs- every one of your customers is impacted? Only in dev?
    every one of your customers is impacted
  • Debug logs that reproduce the issue
    E/PurchasesUIFlutter( 8475): Paywalls require your activity to subclass FlutterFragmentActivity
I/flutter ( 8475): Errrorrr: startPurchasing
I/flutter ( 8475): Errrorrr: startPurchasing: PlatformException(0, Make sure your MainActivity inherits from FlutterFragmentActivity, null, null)
I/flutter ( 8475): Errrorrr: startPurchasing: PlatformException
I/flutter ( 8475): Errrorrr: startPurchasing: PurchasesErrorCode.unknownError
  • Steps to reproduce, with a description of expected vs. actual behavior
    Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
    Just calling this:
      final PaywallResult paywallResult = await RevenueCatUI.presentPaywall(displayCloseButton: true);
      if (paywallResult == PaywallResult.purchased || paywallResult == PaywallResult.restored) {
        onPurchased?.call();
        return true;
      } else if (paywallResult == PaywallResult.cancelled) {
        onCancelled?.call();
      } else {
        onError?.call(LanguageManager.translation.error_try_again);
      }

Describe the bug

This issues is always appear on android, my minSDK 26 and targetSDK is 34.
Also this issue always shown:
This declaration needs opt-in. Its usage must be marked with '@com.revenuecat.purchases.ui.revenuecatui.ExperimentalPreviewRevenueCatUIPurchasesAPI' or '@OptIn(com.revenuecat.purchases.ui.revenuecatui.ExperimentalPreviewRevenueCatUIPurchasesAPI::class)'

Additional context

Add any other context about the problem here.

@arabnology arabnology added the bug Something isn't working label Jul 4, 2024
@RCGitBot
Copy link
Contributor

RCGitBot commented Jul 4, 2024

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

@vegaro
Copy link
Contributor

vegaro commented Jul 5, 2024

As I/flutter ( 8475): Errrorrr: startPurchasing: PlatformException(0, Make sure your MainActivity inherits from FlutterFragmentActivity, null, null) says, you need to make sure your MainActivity in the android folder of your project inherits from FlutterFragmentActivity

Take a look at our tester app https://github.com/RevenueCat/purchases-flutter/blob/main/revenuecat_examples/purchase_tester/android/app/src/main/java/com/revenuecat/purchases_sample/MainActivity.kt where we are inheriting from FlutterFragmentActivity

@arabnology
Copy link
Author

As I/flutter ( 8475): Errrorrr: startPurchasing: PlatformException(0, Make sure your MainActivity inherits from FlutterFragmentActivity, null, null) says, you need to make sure your MainActivity in the android folder of your project inherits from FlutterFragmentActivity

Take a look at our tester app https://github.com/RevenueCat/purchases-flutter/blob/main/revenuecat_examples/purchase_tester/android/app/src/main/java/com/revenuecat/purchases_sample/MainActivity.kt where we are inheriting from FlutterFragmentActivity

Thanks for response,

Is it having any bad side effects, or maybe creating bugs for other plugins? or is it okay to do that?

@vegaro
Copy link
Contributor

vegaro commented Jul 5, 2024

We are not aware of any issues or incompatibilities so far. We require FlutterFragmentActivity because it provides some methods that are not available in FlutterActivity.

If you find any issues with another plugin please let us know so we are aware. Thank you!

@arabnology
Copy link
Author

We are not aware of any issues or incompatibilities so far. We require FlutterFragmentActivity because it provides some methods that are not available in FlutterActivity.

If you find any issues with another plugin please let us know so we are aware. Thank you!

Thank you.

@arabnology
Copy link
Author

We are not aware of any issues or incompatibilities so far. We require FlutterFragmentActivity because it provides some methods that are not available in FlutterActivity.

If you find any issues with another plugin please let us know so we are aware. Thank you!

I have found an issue when using FlutterFragmentActivity:

When you are using FlutterFragmentActivity, the PopScope widget, when pressing the device's back button, it takes you out of the app, which is incorrent.

When using FlutterActivity, the PopScope widget works as expected, when pressing the device's back button, it takes you to the previous screen, which is correct.

@arabnology arabnology reopened this Jul 5, 2024
@vegaro
Copy link
Contributor

vegaro commented Jul 9, 2024

Thanks for reporting that @arabnology

We do need to use a FlutterFragmentActivity, there's no way around that, so we can't rely on a FlutterActivity. I would suggest reporting to the creators of PopScope the issues you're seeing. In any case, I took a quick look and saw this issue that looks related flutter/flutter#128690 (comment) , so maybe this helps:

Since it was only happening in android 13, I figured it had something to do with the android:enableOnBackInvokedCallback="true/false" in the android manifest XML file. I set it previously to true because of something I don't exactly remember, and resetting it back to false seems to have, hopefully, fix it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants