Posts tagged with admob

I'm trying to put advertisements on my app, I put my app on amazon app store and then approved by google admob I set up Ad Unit ID (next level promotion) and put in both the xml and java part the appropriate code for it to work however I still don't get any Ad bar on the home of my app. Does anyone have any idea why it doesn't come up?

Java:

   ` MobileAds.initialize(this, initializationStatus -> {});     // Create an AdView and set the ad unit ID and ad size     adView = new AdView(this);     adView.setAdUnitId("*******");      adView.setAdSize(AdSize.BANNER);     // Add the AdView to your layout     LinearLayout adContainer = findViewById(R.id.ad_container);     if (adContainer != null) {         adContainer.addView(adView);         // Load an ad         AdRequest adRequest = new AdRequest.Builder().build();         adView.loadAd(adRequest);     }` 

XML:

       `<com.google.android.gms.ads.AdView         android:id="@+id/ad_container"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_alignParentBottom="true"         app:adSize="BANNER"         app:adUnitId="***" />` 

I have implemented react-native-google-mobile-ads.. all. thing are. working fine but i want but there is some issue.

  1. When ever a system dialogue is open. like Alert.alert() then an app open ads is appeared.
  2. The Second issue is that app open ads appears after the interstitial ad is closed.
  3. App Open ads are appears when ever a permission dialogue is opened.
  4. I want to hide screen content behind the app open ads.

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 app was getting too high CTR for AppOpenAd which was around 35%-40%. So after looking for the issue I found that the AppOpen Ad is displaying the AppContent background in place of the advertisement. Below are the screenshots to demonstrate the exact issue.

So, in normal implementation as per the Google Admob Documentation. Below is the picture of what is exactly happening at many times. There is a comparison between the perfect display and problem happening display.

So, to work around I tried setting the background to the AdActivity with the following style and theme in Manifest file.

<style name="Theme.AppThemeNoActionBar.AdTheme" ><item name="android:background">@color/black</item>     <item name="android:windowBackground">@color/black</item>     <item name="android:windowExitAnimation">@null</item>     <item name="android:windowEnterAnimation">@null</item></style>

And setting it into manifest file

<activity         android:name="com.google.android.gms.ads.AdActivity"         android:theme="@style/Theme.AppThemeNoActionBar.AdTheme"         tools:replace="android:theme"/> 

But still the issue remained same. Here the comparison picture.

I need to load a Portrait Full-screen native ad.

I have set the nativeAdOptions like these
val nativeAdOptions = NativeAdOptions.Builder().setMediaAspectRatio(MediaAspectRatio.PORTRAIT).build()

and load the ad like this

AdLoader.Builder(context, adUnitId).withNativeAdOptions(nativeAdOptions) 

Even I set the MediaAspectRatio to MediaAspectRatio.PORTRAIT. I am getting landscape ads.

Is there any issue with Google Ad Manager SDK or Do I need to specify any extra AdOptions?