Question

Paywall issues with flutter-android

  • 5 January 2024
  • 4 replies
  • 269 views

Badge +4

unable to build android with on a flutter project enabled for paywalls. was working fine with previous purchases package but looking at below error. 

notes: tried updating java version to 17 and respective changes in gradle files etc..,

increased minSdkVersion, separate note was able to build on iOS and paywall works as expected

 

logs here

Caused by: java.lang.RuntimeException: Failed to transform '/Users/CC/.gradle/caches/modules-2/files-2.1/androidx.compose.material3/material3/1.1.0/dfa0976101de9daf0c4676fb7227fd540d4d1a08/material3-1.1.0.aar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 61. (Run with --stacktrace for more details.)

 

 


4 replies

Userlevel 4
Badge +6

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");
Badge +5

@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 ?

Badge +1

@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!

Reply