Posts tagged with flutter

I am running google ads campaign for IOS application , I have implemented firebase analytics in our application ,I have created an event in analytics and imported these events like first_open , screen_view on ads also , I have done all things which is require for ads still I am not getting downloads , In 4 to 5 days we got 444 Impressions , 9 Clicks and 0 install. It is Working fine for android app campaign but it is not working for IOS app campaign. Is there any code issue or we are doing something wrong while running campaign , guys please help me out with this issue.

this is the error which i get while running the command flutter build apk --release

* What went wrong: A problem occurred configuring project ':google_mobile_ads'. > Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.    > Namespace not specified. Please specify a namespace in the module's build.gradle file like so:      android {          namespace 'com.example.namespace'      } 

but i have it in my gradle file . i am giving here my app level build.gradle file

plugins {     id "com.android.application"     id "kotlin-android"     id "dev.flutter.flutter-gradle-plugin" } def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) {     localPropertiesFile.withReader('UTF-8') { reader ->         localProperties.load(reader)     } } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) {     flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) {     flutterVersionName = '1.0' } android {     namespace "com.example.tripp"     compileSdkVersion = 33     ndkVersion flutter.ndkVersion     compileOptions {         sourceCompatibility JavaVersion.VERSION_1_8         targetCompatibility JavaVersion.VERSION_1_8     }     kotlinOptions {         jvmTarget = '1.8'     }     sourceSets {         main.java.srcDirs += 'src/main/kotlin'     }     defaultConfig {         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).         applicationId "com.busdekho.tripp"         // You can update the following values to match your application needs.         // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.         minSdkVersion 33         targetSdkVersion flutter.targetSdkVersion         versionCode flutterVersionCode.toInteger()         versionName flutterVersionName                  buildFeatures {         buildConfig = true         }     }     buildTypes {         release {             // TODO: Add your own signing config for the release build.             // Signing with the debug keys for now, so `flutter run --release` works.             signingConfig signingConfigs.debug         }     } } flutter {     source '../..' } dependencies {     implementation 'com.google.android.gms:play-services-ads:22.3.0' } 

the below one is my project level gradle file which have small additions

buildscript {     ext.kotlin_version = '1.7.10'     repositories {         google()         mavenCentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:8.0.0'         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"     } } allprojects {     repositories {         google()         mavenCentral()     } } rootProject.buildDir = '../build' subprojects {     project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects {     project.evaluationDependsOn(':app') } tasks.register("clean", Delete) {     delete rootProject.buildDir } 

can any one help me in solving this problem . i am also giving you the complete error code that i am get in cmd

PS C:\Users\hp\Desktop\myprojects\tripp> flutter build apk --release FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':google_mobile_ads'. > Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.    > Namespace not specified. Please specify a namespace in the module's build.gradle file like so: android {          namespace 'com.example.namespace'      } If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 2s Running Gradle task 'assembleRelease'...                            3.3s Gradle task assembleRelease failed with exit code 1 PS C:\Users\hp\Desktop\myprojects\tripp> 

As shown in the image admob banner ad is cut off or stretched.

If I use AdSize.banner widget does not take the entire width but shows the ad correctly. If I use full-banner the ad is stretched.

How do I get the banner to fit the full width of the screen and show the content correctly (without cut off or streached)?

class _AdBannerState extends State<AdBanner>{   BannerAd? _inlineAdaptiveAd;   bool _isLoaded = false;   AdSize? _finalSize;   @override   void didChangeDependencies() {     super.didChangeDependencies();     _loadAd();   }   void _loadAd() async {     await _inlineAdaptiveAd?.dispose();     setState(() {       _inlineAdaptiveAd = null;       _isLoaded = false;     });     // Get an inline adaptive size for the current orientation.     AdSize size = AdSize.fullBanner;     _inlineAdaptiveAd = BannerAd(       adUnitId: AdHelper.bannerAdUnitId,       size: size,       request: const AdRequest(),       listener: BannerAdListener(         onAdLoaded: (Ad ad) async {           debugPrint('Inline adaptive banner loaded: ${ad.responseInfo}');           // After the ad is loaded, get the platform ad size and use it to           // update the height of the container. This is necessary because the           // height can change after the ad is loaded.           BannerAd bannerAd = (ad as BannerAd);           _finalSize = await bannerAd.getPlatformAdSize();           // if (size == null) {           //   debugPrint(           //       'Error: getPlatformAdSize() returned null for $bannerAd');           //   return;           // }           setState(() {             _inlineAdaptiveAd = bannerAd;             _isLoaded = true;           });         },         onAdFailedToLoad: (Ad ad, LoadAdError error) {           debugPrint('Inline adaptive banner failedToLoad: $error');           ad.dispose();         },       ),     );     await _inlineAdaptiveAd!.load();   }   @override   Widget build(BuildContext context) {     return (_inlineAdaptiveAd != null && _isLoaded && _finalSize != null)         ? Expanded(             child: SizedBox(                 width: _finalSize!.width.toDouble(),                 height: _finalSize!.height.toDouble(),                 child: AdWidget(                   ad: _inlineAdaptiveAd!,                 )))         : const SizedBox(             width: 0,             height: 0,           );   }   @override   void dispose() {     _inlineAdaptiveAd?.dispose();     super.dispose();   } } 

I have implemented a simple game for which I have added banner, interstitial and reward ads.

The banner and interstitial ads work perfectly both on test and my own google adMob adIds. However only the reward ads do not work. Even the test reward ad gives an error 3.

The code is as follows

Future<void> _loadRewardedAd() async {     if (this.mounted) {       setState(() {         loading = true;       });     }     await RewardedAd.load(         adUnitId: TestAdHelper.rewardedAdUnitId,         request: const AdRequest(),         rewardedAdLoadCallback: RewardedAdLoadCallback(onAdLoaded: (ad) {           ad.fullScreenContentCallback =               FullScreenContentCallback(onAdDismissedFullScreenContent: (ad) {             ad.dispose();             _rewardedAd = null;             widget.close(domain.Dialog.awardAd, show: false);           });           _rewardedAd = ad;         }, onAdFailedToLoad: (error) {           _rewardedAd?.dispose();           failedAttempts++;           log("failed to load reward ad $error");           failedAttempts <= 3               ? 2.seconds.delay().then((value) => _loadRewardedAd())               : null;           setState(() {             loading = false;             didntLoad = true;           });         }));   } 

and

ElevatedButton(     style: ElevatedButton.styleFrom(         minimumSize: Size(90, 60),         backgroundColor: Colors.greenAccent.shade700),     onPressed: () async {       await _loadRewardedAd().then((value) async {         await _rewardedAd?.show(             onUserEarnedReward: (_, reward) {           widget.incrementCoins();           widget.close(domain.Dialog.awardAd,               show: false);         });       });     },     child: loading         ? CircularProgressIndicator(             color: Colors.white,             backgroundColor: Colors.white38,           )         : Icon(             Icons.ondemand_video_rounded,             size: 40,           )) 

The test ID helper class uses the following IDs

static String get rewardedAdUnitId {     if (Platform.isAndroid) {       return "ca-app-pub-3940256099942544/5224354917";     } else if (Platform.isIOS) {       return "ca-app-pub-3940256099942544/1712485313";     } else {       throw UnsupportedError("Unsupported platform");     }   } 

I have tried looking up this issue but to no avail, only people agreeing that they have the same issue in threads that go as far as 2021.

I also get this error in the debug console, the number varies although 3 is the most common

I/flutter (10788): Ad with id 1 is not available for onAdFailedToLoad. I/flutter (10788): Ad with id 2 is not available for onAdFailedToLoad. I/flutter (10788): Ad with id 3 is not available for onAdFailedToLoad.

My target is to get the information in my app of the origin of the user: does he/she come from a Google Ad click?

The flow is: Google Ad -> AppStore/GooglePlay -> App Download -> App Opening -> Firebase custom event (like Register or whatever).

When we connect Firebase and Google Ad together, we can have the conversion funnel available in Google Ads.

It means that the tracker is available in Firebase within the iOS/Android app.

Is it possible to retrieve this tracker from Firebase? I want to send this information to Mixpanel that the user downloaded an app thanks to a Google Ad click.

PS: any answer is good, but I will use React Native or Flutter to implement this behavior.

Thanks!