Closed under3415 closed 1 year ago
Hi @under3415 There was a similar issue here as well. It looks like an issue from ads library rather than this Flutter ads plugin since I also see the issue with Android native reward sample code (you can try it to check this).
Also, I see there is a related issue that you can take a look on it: https://groups.google.com/g/google-admob-ads-sdk/c/4BGujai2Cig/m/3t2tuJmfBgAJ
We can close it if it is not a flutter issue. There is no related issue that is in progress though. This whole system of bug reporting is starting to feel like an exercise in stalling and finger pointing, very unproductive. I thought ads were Google's number one priority, it is their bread and butter, it is surprising how little they seem to care! :-D
I watch some rewarded ads recently on apps/games and see it also can not be closed until it finished (even pressing back button or close button on the top corner). So I think it could be a change with ads activity that's out of the scope of this flutter plugin.
I will close this issue from here. If you disagree, please write in the comments and I will reopen it. Thanks!
OK to close it. Is there somewhere else I could file this bug for the Google ads team?
You can try opening a new conversation at https://groups.google.com/g/google-admob-ads-sdk
Plugin Version
3.0.0
Steps to Reproduce
flutter create bug
.main.dart
files as follows:void main() { runApp(const MyApp()); }
class MyApp extends StatelessWidget { const MyApp({super.key});
// This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Google Ads Demo'), ); } }
class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title});
final String title;
@override State createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
RewardedAd? _rewardedAd;
bool _loadingAd = false;
Future _adBuyDialog() {
return showGeneralDialog(
context: context,
barrierDismissible: false,
transitionBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(
opacity: animation,
child: ScaleTransition(
scale: animation,
child: child,
),
);
},
pageBuilder: (context, animation, secondaryAnimation) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.amber,
body: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
elevation: 0,
minimumSize: const Size(
150,
50,
)),
onPressed: () async {
await showRewardedAd();
if (!mounted) {
return;
}
Navigator.pop(context);
},
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"Watch Ad",
style: TextStyle(color: Colors.black, fontSize: 12),
),
),
),
),
);
},
);
}
Future get _createRewardedAd async {
_loadingAd = true;
await RewardedAd.load(
adUnitId: 'ca-app-pub-3940256099942544/5224354917', //sample ads
request: const AdRequest(),
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (RewardedAd ad) {
_rewardedAd = ad;
_loadingAd = false;
},
onAdFailedToLoad: (LoadAdError error) {
_rewardedAd = null;
_loadingAd = false;
},
));
}
Future showRewardedAd() async {
int tries = 0;
int maxTries = 5;
}
Future _initAds() async {
await MobileAds.instance.initialize();
await _createRewardedAd;
return true;
}
@override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: Text(widget.title), ), body: FutureBuilder( future: _initAds(), builder: (context, snapshot) { if (snapshot.hasData) { return const Center( child: Text( 'Click to show test ad', ), ); } else { return const Center( child: SizedBox( width: 60, height: 60, child: CircularProgressIndicator( strokeWidth: 8.0, color: Color.fromRGBO(69, 162, 158, 1.0), ), ), ); } }), floatingActionButton: FloatingActionButton( onPressed: _adBuyDialog, tooltip: 'Show Ad', child: const Icon(Icons.add), ), ), ); } }
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713"/>
[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.19045.2965], locale en-US) • Flutter version 3.10.0 on channel stable at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 84a1e904f4 (2 days ago), 2023-05-09 07:41:44 -0700 • Engine revision d44b5a94c9 • Dart version 3.0.0 • DevTools version 2.23.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at C:\Users\user\AppData\Local\Android\sdk • Platform android-33, build-tools 33.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) • All Android licenses accepted.
[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.5) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.5.33627.172 • Windows 10 SDK version 10.0.22621.0 X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools
[√] Android Studio (version 2022.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
[√] VS Code (version 1.78.1) • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.64.0
[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.2965] • Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.93 • Edge (web) • edge • web-javascript • Microsoft Edge 113.0.1774.35
[√] Network resources • All expected network resources are available.