Posts tagged with android

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="***" />` 

Android code for sending data to firebase analytics:-

FirebaseAnalytics logger = FirebaseAnalytics.getInstance(activity); Bundle bundle = new Bundle(); bundle.putString("Type", type); logger.logEvent("RazorPay", bundle); 

This event is correctly recorded in Firebase Analytics but in Campaign section it have displayed as (not set) https://i.sstatic.net/X8E7i.png

I have also check log in Firebase debug view all data are correctly recorded https://i.sstatic.net/YfZ1Z.png

Does anyone understand what wrong is going here, why display (not set) value?, what exactly show instead of (not set)

Thank you in advance

The problem is - is there a way to retrieve the ad with size of 728*90 and set it to my view which is 600*90?

The problem is that the Ad is truncated in the portrait mode while in the landscape it looks good.

Portrait:

Landscape:

I use tablet and in order to represent the Ad I use AdManagerAdView.

I found out where the problem is - the problem is that the app requests the ad with the size of (w:) 728 * (h:) 90, however, the width of the tablet is 600dp, so it is obvious that 128dp is kind of out of the screen.

I tried to check all possible ad sizes described here - https://developers.google.com/ad-manager/mobile-ads-sdk/android/banner#banner_sizes

these sizes:

            this.setAdSizes(AdSize(320, 50)) +             this.setAdSizes(AdSize(320, 100))             this.setAdSizes(AdSize(300, 250)) +             this.setAdSizes(AdSize(468, 60))             this.setAdSizes(AdSize(728, 90)) + 

However, I wasn't able to retrieve all the ads by thier sizes, I only got these:

            this.setAdSizes(AdSize(320, 50)) +             this.setAdSizes(AdSize(300, 250)) +             this.setAdSizes(AdSize(728, 90)) + 

From this point I made a conclusion that a publisher provides only these specific ads sizes. For me it means that if it is nessasary to use smaler ad that 728*90 the next size would be 300*250 which is more than twice narrowed than I need (600dp).

So the next idea was to use NativeAd (https://developers.google.com/ad-manager/mobile-ads-sdk/android/native/start), however, I get an error:

onAdFailedToLoad: {                    "Code": 3,                    "Message": "No ad config.",                    "Domain": "com.google.android.gms.ads",                    "Cause": "null",                    "Response Info": {                      "Response ID": "null",                      "Mediation Adapter Class Name": "",                      "Adapter Responses": []                    }                  } 

So as far as I undestand there is no way just to start to use NativeAd, it should be configurated on the publisher end first (as far as I see), because once I tried to made a request with the same credentials (as for AdManagerAdView), I get this config error, looks like NativeAd config is not existing on the publisher end.

So, finally the question is - is there a way to retrieve the ad with size of 728*90 and set it to my view which is 600*90?

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.