Hey @manasa !
For Flutter in order to get paywalls working on Android, you will need to do the following:
- Change your
MainActivity
to subclass FlutterFragmentActivity
instead of FlutterActivity
. Also, the min sdk version of the new package is 24
. Please make sure your app's android/build.gradle
minSdkVersion has that or a higher version. - Add
purchases-ui-flutter
in your pubspec.yaml
: - Make sure that you add the following dependency: purchases_ui_flutter: 6.15.0-beta.4
Usage:
import 'package:purchases_ui_flutter/purchases_ui_flutter.dart';await RevenueCatUI.presentPaywallIfNeeded("pro");
@Michael Fogel .
Sorry to hijack this thread, but its in the same line as your reply.
I just came across an issue when changing the MainActivity to a fragment app. I have an app on the playstore that uses an audio player, in my case AudioFilePlayers.
If my app is using FlutterFragmentActivity I have several issues with the audio player in wich i cannot get the media items to work, pause, etc. I was really looking forward for paywalls but this is a deal breaker.
I found this after hours of debugging in wich I said the only big thing i changed was the Activity to a FragmentActivity, and this was the root cause. As changing it back fixed the issue.
The paywalls dependency on a FragmentActivity is not going to change anytime ?
@Michael Fogel
Hi, this doesnt work for me.
I changed the minsdkVersion and the MainActivity to a FlutterFragmentActivity, but the emulator gets an error message and on my phone the app crashes instantly.
Will there be an updated version of the Paywall soon, that wont use FlutterFragmentActivity, or should i write my own paywall?
@Philip Donegan
I had this exact problem with audio_service package but I was able to fix this by cloning the audio_service source code and change its AudioServiceActivity.java file so that it extends FlutterFragmentActivity instead of FlutterActivity. Then I just added this local package to pubspec.yaml. It is a bit hacky but at least now both paywall and audio service works. Maybe something similar works with AudioFilePlayers!
@Philip Donegan @Riku K
to use audio_service you just add android:name="com.ryanheise.audioservice.AudioServiceFragmentActivity" inside of your activity
<activity
android:name="com.ryanheise.audioservice.AudioServiceFragmentActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
and change MainActivity.kt to
package com.name
import io.flutter.embedding.android.FlutterFragmentActivity
import com.ryanheise.audioservice.AudioServiceFragmentActivity
class MainActivity: AudioServiceFragmentActivity()
I also get the same issues:
Paywalls require your activity to subclass FlutterFragmentActivity
00): Paywalls require your activity to subclass FlutterFragmentActivity
I/flutter (21300): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (21300): PlatformException(0, Make sure your MainActivity inherits from FlutterFragmentActivity, null, null)
I/flutter (21300): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
I/flutter (21300): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
I/flutter (21300): <asynchronous suspension>
I/flutter (21300): #2 RevenueCatUI.presentPaywall (package:purchases_ui_flutter/purchases_ui_flutter.dart:8:7)
I/flutter (21300): <asynchronous suspension>
I/flutter (21300): #3 _configureSDK (package:english_booster/main.dart3)
I/flutter (21300): <asynchronous suspension>
I/flutter (21300): #4 main (package:english_booster/main.dart:67:3)
I/flutter (21300): <asynchronous suspension>
main.dart code:
await Purchases.setLogLevel(LogLevel.debug);PurchasesConfiguration? configuration;if (Platform.isAndroid) { configuration = PurchasesConfiguration(googleApiKey);}if(configuration !=null) { await Purchases.configure(configuration); await RevenueCatUI.presentPaywallIfNeeded(entitlementID);}
Hey @md-mafujul-islam-809ce9 ,
Which version of the SDK are you using? Also, are you possibly presenting the paywall prior to configuring the SDK?