googleads-mobile-flutter: Google Mobile Ads SDK Developers Privacy • Terms Flutter App crashes when "google_mobile_ads: ^2.3.0" is added into pubspec.yaml
Plugin Version
“google_mobile_ads: ^2.3.0”
So I want to put ads into my app. I followed the instructions from (https://developers.google.com/ad-manager/mobile-ads-sdk/flutter/banner/get-started) and added everything from the docs. When ever I run the app it stops at
Running Gradle task ‘assembleDebug’… √ Built build\app\outputs\flutter-apk\app-debug.apk.
then the app crashes.
Here the pubspec, AndroidManifest and main.dart:
pubspec.yaml:
google_mobile_ads: ^2.3.0
AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
and main.dart:
import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
MobileAds.instance.initialize();
await Firebase.initializeApp();
runApp(const MyApp(
backgroundColor: Colors.black,
));
}
The app runs without the
google_mobile_ads: ^2.3.0
Others:
minSdkVersion 23
compileSdkVersion 33
implementation 'com.google.android.gms:play-services-ads:7.5.0'
implementation 'com.android.support:multidex:1.0.3'
I Tried removing each code from the docs starting from
MobileAds.instance.initialize();
and running it each time. Found out that the
google_mobile_ads: ^2.3.0
Was the one causing it.
Im new to this so any help is appreciated
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 17
@TiMeJuMp Thank you for reply and solved my issue.
I solve by another way i check library’s example and do same as example it’s works for me and also chnage in pubspec.yaml like this : environment: sdk: ‘>=2.18.6 ❤️.0.0’ to environment: sdk: ‘>=2.12.0 ❤️.0.0’
it’s wworks fine for me.
Hello again, I have run and tested the sample ads and it worked perfectly. I will try and apply to my code to see if it works. Thanks again
@TiMeJuMp As I see from your sample project, it’s incompleted setup since there is missing
APPLICATION_IDon AndroidManifest.xml file.Please also check guideline from the error message: