invertase / react-native-google-mobile-ads

React Native Google Mobile Ads enables you to monetize your app with AdMob.
https://docs.page/invertase/react-native-google-mobile-ads
Other
702 stars 142 forks source link

[🐛] ANCHORED_ADAPTIVE_BANNER does not work on android #359

Closed josephto closed 1 year ago

josephto commented 1 year ago

What happened?

Inside ReactNativeGoogleMobileAdsCommon.java's getAdSizeForAdaptiveBanner method (https://github.com/invertase/react-native-google-mobile-ads/blob/8bbfc058b20f599acc3fd91d0145c4f974bf2d09/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java#L46), the try catch throws and error:

Error thrown: java.lang.ClassCastException: {{com.myapp}}.MainActivity cannot be cast to com.facebook.react.bridge.ReactContext

As a result, the AdSize.Banner is always returned instead of an adaptive AdSize:

Screenshot 2023-04-07 at 5 45 49 PM

Platforms

Only on Android

React Native Info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M2
    Memory: 70.19 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
    Watchman: 2023.01.30.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/joseph/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9514443
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.18 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^18.2.0 => 18.2.0
    react-native: 0.71.3 => 0.71.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Are your using Typescript?

package.json

{
  "name": "swingpoints",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start:local": "TAMAGUI_TARGET=native react-native start --reset-cache",
    "start:dev": "NODE_ENV=development TAMAGUI_TARGET=native react-native start --reset-cache",
    "start:prod": "NODE_ENV=production TAMAGUI_TARGET=native react-native start --reset-cache",
    "test": "jest",
    "relay": "relay-compiler",
    "watch-relay": "relay-compiler --watch",
    "codegen": "graphql-codegen --config codegen.ts",
    "local": "watchman shutdown-server | concurrently \"npm:watch-relay\" \"npm:start:local\"",
    "dev": "watchman shutdown-server | concurrently \"npm:watch-relay\" \"npm:start:dev\"",
    "prod": "watchman shutdown-server | concurrently \"npm:watch-relay\" \"npm:start:prod\"",
    "generate-icons": "npx react-native generate-bootsplash ./src/assets/originalAppIcon.png --background-color=f0f0f0   --logo-width=100 --assets-path=./src/assets --flavor=main",
    "clean": "react-native-clean-project",
    "postinstall": "react-native setup-ios-permissions && pod-install"
  },
  "dependencies": {
    "@accounts/apollo-link": "^0.32.1",
    "@accounts/client": "^0.33.1",
    "@accounts/client-password": "^0.32.2",
    "@accounts/graphql-client": "^0.33.1",
    "@apollo/client": "^3.7.7",
    "@notifee/react-native": "^7.5.0",
    "@react-native-async-storage/async-storage": "^1.17.11",
    "@react-native-community/hooks": "^3.0.0",
    "@react-native-firebase/analytics": "^17.3.2",
    "@react-native-firebase/app": "^17.3.1",
    "@react-native-firebase/messaging": "^17.3.1",
    "@react-native-picker/picker": "^2.4.9",
    "@react-navigation/bottom-tabs": "^6.5.4",
    "@react-navigation/native": "^6.1.2",
    "@react-navigation/native-stack": "^6.9.9",
    "@tamagui/babel-plugin": "^1.7.6",
    "@tamagui/config": "^1.7.6",
    "@tamagui/themes": "^1.7.6",
    "expo": "^47.0.0",
    "expo-linear-gradient": "~12.0.1",
    "moment": "^2.29.4",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-native": "0.71.3",
    "react-native-blob-util": "^0.17.1",
    "react-native-bootsplash": "^4.5.2",
    "react-native-device-info": "^10.3.0",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-google-mobile-ads": "^10.0.1",
    "react-native-map-clustering": "^3.4.2",
    "react-native-maps": "^1.4.0",
    "react-native-pdf": "^6.6.2",
    "react-native-permissions": "^3.8.0",
    "react-native-reanimated": "^3.0.2",
    "react-native-reanimated-carousel": "^3.3.0",
    "react-native-restart": "^0.0.27",
    "react-native-safe-area-context": "^4.5.0",
    "react-native-screens": "3.3.0",
    "react-native-svg": "^13.8.0",
    "react-native-svg-charts": "^5.4.0",
    "react-native-toast-message": "^2.1.5",
    "react-native-vector-icons": "^9.2.0",
    "react-native-web": "^0.18.12",
    "react-native-webview": "^11.26.1",
    "react-relay": "^14.1.0",
    "react-test-renderer": "^18.2.0",
    "tamagui": "^1.7.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/preset-typescript": "^7.18.6",
    "@babel/runtime": "^7.20.0",
    "@graphql-cli/codegen": "^2.4.25",
    "@graphql-codegen/cli": "2.16.5",
    "@graphql-codegen/client-preset": "1.3.0",
    "@graphql-codegen/schema-ast": "^2.6.1",
    "@react-native-community/eslint-config": "^3.0.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/react": "^18.0.24",
    "@types/react-native-svg-charts": "^5.0.12",
    "@types/react-native-vector-icons": "^6.4.13",
    "@types/react-relay": "^14.1.3",
    "@types/react-test-renderer": "^18.0.0",
    "@types/relay-runtime": "^14.1.6",
    "babel-jest": "^29.2.1",
    "babel-plugin-relay": "^14.1.0",
    "babel-plugin-transform-inline-environment-variables": "^0.4.4",
    "concurrently": "^7.6.0",
    "eslint": "^8.19.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "graphql": "^15.0.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "^0.73.7",
    "prettier": "^2.4.1",
    "react-native-clean-project": "^4.0.1",
    "react-native-dotenv": "^3.4.8",
    "relay-compiler": "^14.1.0",
    "typescript": "4.8.4"
  },
  "jest": {
    "preset": "react-native"
  },
  "prettier": {
    "bracketSpacing": true
  },
  "reactNativePermissionsIOS": [
    "AppTrackingTransparency"
  ]
}

app.json

{
  "name": "SwingPoints",
  "displayName": "SwingPoints",
  "react-native-google-mobile-ads": {
    "android_app_id": "***********************************",
    "ios_app_id": "***********************************",
    "user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
  }
}

ios/Podfile

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# 
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# 
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true
$RNFirebaseAnalyticsWithoutAdIdSupport = true
$RNGoogleMobileAdsAsStaticFramework = true
target 'SwingPoints' do
  use_expo_modules!
  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end

  $static_framework = [
      'react-native-maps',
      'react-native-google-maps',
      'Google-Maps-iOS-Utils',
      'GoogleMaps',
      'RNPermissions'
      ]

  # React Native Maps dependencies
  # The following line is only needed if building on an Apple silicon Mac without rosetta.
  pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'

  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
#    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'SwingPointsTests' do
    inherit! :complete
    # Pods for testing
  end

  # ****** THIS IS THE MAGIC ******
  pre_install do |installer|
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
          installer.pod_targets.each do |pod|
              if $static_framework.include?(pod.name)
                  def pod.build_type;
                  Pod::BuildType.static_library # >= 1.9
              end
          end
      end
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath('com.google.gms:google-services:4.3.15')
    }
}

android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'

project.ext.vectoricons = [
        iconFontNames: [ 'MaterialIcons.ttf', 'FontAwesome5_Brands.ttf', 'FontAwesome5_Regular.ttf', 'FontAwesome5_Solid.ttf' ] // Name of the font files you want to copy
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

import com.android.build.OutputFile

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
    // codegenDir = file("../node_modules/react-native-codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to create four separate APKs instead of one,
 * one for each native architecture. This is useful if you don't
 * use App Bundles (https://developer.android.com/guide/app-bundle/)
 * and want to have separate APKs to upload to the Play Store.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Private function to get the list of Native Architectures you want to build.
 * This reads the value from reactNativeArchitectures in your gradle.properties
 * file and works together with the --active-arch-only flag of react-native run-android.
 */
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "dance.westie"
    defaultConfig {
        applicationId "dance.westie"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 600000
        versionName "6.0.0"
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        // release {
        //     // Caution! In production, you need to generate your own keystore file.
        //     // see https://reactnative.dev/docs/signed-apk-android.
        //     signingConfig signingConfigs.debug
        //     minifyEnabled enableProguardInReleaseBuilds
        //     proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        //     signingConfig signingConfigs.release
        // }
        release {
            signingConfig signingConfigs.release
        }
    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }

        }
    }

    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libjsc.so'
        pickFirst 'lib/arm64-v8a/libjsc.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
    implementation("androidx.core:core-splashscreen:1.0.0")

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android/settings.gradle

rootProject.name = 'SwingPoints'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.INTERNET"/>
  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/BootTheme">
    <meta-data android:name="com.google.android.geo.API_KEY" android:value="*************************"/>
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_stat_originalappicon" />
    <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="swingpoints"/>
      </intent-filter>
    </activity>
  </application>
</manifest>
mikehardy commented 1 year ago

Careful with this - version skew detected:

    "@react-native-firebase/analytics": "^17.3.2",
    "@react-native-firebase/app": "^17.3.1",
    "@react-native-firebase/messaging": "^17.3.1",

--> https://invertase.io/blog/react-native-firebase-versioning

PRs happily accepted if you can find a patch that works for you inside node_modules to fix the issue you describe, if I recall correctly during review we were pretty sure that the Activity there would also be something in the React object hierarchy thus the cast would succeed. Is your app some sort of brownfield / mixed react-native/non-react-native set of objects?

josephto commented 1 year ago

Is your app some sort of brownfield / mixed react-native/non-react-native set of objects?

No, not that I'm aware of. My app is a bare React Native app

dylancom commented 1 year ago

Might be introduced by: https://github.com/invertase/react-native-google-mobile-ads/commit/3b1f34cb850d89555f6350d5c8b50e4c242a3a78 ?

UPDATE: could reproduce with our example app. Reverting https://github.com/invertase/react-native-google-mobile-ads/pull/345 fixes the issue (@aidan-24com).

Caused by: https://github.com/invertase/react-native-google-mobile-ads/blob/main/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeAdView.java#L19 Removing this line fixes the issue.

dylancom commented 1 year ago

I reverted #345 and re-opened #188. If you update to 10.1.1 it should work fine again. Thanks for reporting!

aidan-24com commented 1 year ago

apologies for the back and forth with this, but I believe the new PR is a cleaner approach and also only handful of lines

mikehardy commented 1 year ago

:tada: This issue has been resolved in version 10.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

josephto commented 1 year ago

Exception is not being thrown anymore. However, I'm noticing that in development mode, the ads are properly sized to the width of the device, but in release mode, the ads are not. Anybody have a potential explanation for this?

Release: Screenshot 2023-04-12 at 3 51 20 PM

Development: Screenshot 2023-04-12 at 3 53 16 PM

aidan-24com commented 1 year ago

@josephto are you using GAM ads?

josephto commented 1 year ago

@aidan-24com no, should I be? I'm not sure when i should use GAMBannerAd vs a BannerAd. Here is my relevant code snippet

  const requestNonPersonalizedAdsOnly =
    Platform.select({
      ios: !(appTrackingTransparency === RESULTS.GRANTED),
      android: false,
    }) ?? false;

  const bannerSize = BannerAdSize.ANCHORED_ADAPTIVE_BANNER;

  return (
    <AdsContext.Provider
      value={{
        topBannerAd:
          showAds && appTrackingTransparency ? (
            <Stack alignSelf="center">
              <BannerAd
                unitId={topBannerAdUnitId}
                size={bannerSize}
                requestOptions={{
                  requestNonPersonalizedAdsOnly,
                }}
              />
            </Stack>
          ) : null,
        bottomBannerAd:
          showAds && appTrackingTransparency ? (
            <Stack alignSelf="center">
              <BannerAd
                unitId={bottomBannerAdUnitId}
                size={bannerSize}
                requestOptions={{
                  requestNonPersonalizedAdsOnly,
                }}
              />
            </Stack>
          ) : null,
      }}
    >
      {children}
    </AdsContext.Provider>
aidan-24com commented 1 year ago

hmm, the change I made recently is now only for GAM banner ads. we only use GAM for our apps, so not sure why they are different for you.

maybe try use the same ad unit in both dev and release, to confirm that is not just the ads themselves?

josephto commented 1 year ago

I reverted #345 and re-opened #188. If you update to 10.1.1 it should work fine again. Thanks for reporting!

I think my question is related to @dylancom's comment above here that fixes the ANCHORED_ADAPTIVE_BANNER and not to your recent PR

dylancom commented 1 year ago

The implementation seems fine. Also the Test Ad label on top suggests this. For a more detailed insight in why the admob inventory is returning a smaller ad in the available space you'd have to ask the AdMob forums. I would suggest testing on a real device with a production ready APK.